summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-09-06 11:29:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-09-06 11:29:52 -0400
commitb28c862a6c11c5f9fc77687124747d551b7c74a1 (patch)
tree15ff4e427452541cf04f2face6a17033d5a1bdee /src
parent70354dd560c7cdf4bf32653e9687051bf8abcb0e (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/date.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index b141a1a949a..52973055105 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -2721,6 +2721,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