interval-week-and-quarter-fixes.patch
text/x-diff
Filename: interval-week-and-quarter-fixes.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/adt/timestamp.c | 8 | 1 |
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index ed03c50a6d..7177c1a62f 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -5992,12 +5992,19 @@ interval_part_common(PG_FUNCTION_ARGS, bool retnumeric) intresult = tm->tm_mday; break; + case DTK_WEEK: + intresult = tm->tm_mday / 7; + break; + case DTK_MONTH: intresult = tm->tm_mon; break; case DTK_QUARTER: - intresult = (tm->tm_mon / 3) + 1; + if (tm->tm_year >= 0) + intresult = (tm->tm_mon / 3) + 1; + else + intresult = -((-tm->tm_mon / 3) + 1); break; case DTK_YEAR: