postgres.git / summary / log / commit / refs
commit eb3c8d24808a4d3ee8a257f4b856d5583b5cfdaa
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon Sep 06 15:29:52 2021 +0000
First released in: 9.6.24, 10.19, 11.14, 12.9, 13.5, 14.0
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 (388e71af8)
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
src/backend/utils/adt/date.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 04a9b82bb4d..8e9473a9e14 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -2801,6 +2801,8 @@ timetz_zone(PG_FUNCTION_ARGS)
struct pg_tm *tm;
tm = pg_localtime(&now, tzp);
+ tm->tm_year += 1900; /* adjust to PG conventions */
+ tm->tm_mon += 1;
tz = DetermineTimeZoneAbbrevOffset(tm, tzname, tzp);
}
else
[parent: 60bf7e69b078]