Skip to content

Commit d8a266c

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 9f9ae01 commit d8a266c

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
@@ -2832,6 +2832,8 @@ timetz_zone(PG_FUNCTION_ARGS)
28322832
struct pg_tm *tm;
28332833

28342834
tm = pg_localtime(&now, tzp);
2835+
tm->tm_year += 1900; /* adjust to PG conventions */
2836+
tm->tm_mon += 1;
28352837
tz = DetermineTimeZoneAbbrevOffset(tm, tzname, tzp);
28362838
}
28372839
else

0 commit comments

Comments
 (0)