Skip to content

Commit 599c73a

Browse files
committed
Fix bogus timetz_zone() results for DYNTZ abbreviations.
timetz_zone() delivered completely wrong answers if the zone was specified by a dynamic TZ abbreviation, because it failed to account for the difference between the POSIX conventions for field values in struct pg_tm and the conventions used in PG-specific datetime code. As a stopgap fix, just adjust the tm_year and tm_mon fields to match PG conventions. This is fixed in a different way in HEAD (388e71a) but I don't want to back-patch the change of reference point. Discussion: https://postgr.es/m/CAJ7c6TOMG8zSNEZtCn5SPe+cCk3Lfxb71ZaQwT2F4T7PJ_t=KA@mail.gmail.com
1 parent 1e9afc8 commit 599c73a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/utils/adt/date.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,6 +3073,8 @@ timetz_zone(PG_FUNCTION_ARGS)
30733073
struct pg_tm *tm;
30743074

30753075
tm = pg_localtime(&now, tzp);
3076+
tm->tm_year += 1900; /* adjust to PG conventions */
3077+
tm->tm_mon += 1;
30763078
tz = DetermineTimeZoneAbbrevOffset(tm, tzname, tzp);
30773079
}
30783080
else

0 commit comments

Comments
 (0)