From 3dbbbbf8e98329e1eea9920436defc64af3594d3 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 23 Jul 2005 14:25:34 +0000 Subject: Andrew pointed out that the current fix didn't handle dates that were near daylight savings time boudaries. This handles it properly, e.g. test=> select '2005-04-03 04:00:00'::timestamp at time zone 'America/Los_Angeles'; timezone ------------------------ 2005-04-03 07:00:00-04 (1 row) --- src/backend/utils/adt/datetime.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/backend/utils/adt/datetime.c') diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 04ec7cb216a..9e5be7d4cff 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.156 2005/07/22 03:46:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.157 2005/07/23 14:25:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1612,7 +1612,7 @@ DecodeDateTime(char **field, int *ftype, int nf, if (fmask & DTK_M(DTZMOD)) return DTERR_BAD_FORMAT; - *tzp = DetermineLocalTimeZone(tm); + *tzp = DetermineTimeZoneOffset(tm, global_timezone); } } @@ -1620,10 +1620,10 @@ DecodeDateTime(char **field, int *ftype, int nf, } -/* DetermineLocalTimeZone() +/* DetermineTimeZoneOffset() * * Given a struct pg_tm in which tm_year, tm_mon, tm_mday, tm_hour, tm_min, and - * tm_sec fields are set, attempt to determine the applicable local zone + * tm_sec fields are set, attempt to determine the applicable time zone * (ie, regular or daylight-savings time) at that time. Set the struct pg_tm's * tm_isdst field accordingly, and return the actual timezone offset. * @@ -1632,7 +1632,7 @@ DecodeDateTime(char **field, int *ftype, int nf, * of mktime(), anyway. */ int -DetermineLocalTimeZone(struct pg_tm *tm) +DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) { int date, sec; @@ -1648,7 +1648,7 @@ DetermineLocalTimeZone(struct pg_tm *tm) after_isdst; int res; - if (HasCTZSet) + if (tzp == global_timezone && HasCTZSet) { tm->tm_isdst = 0; /* for lack of a better idea */ return CTimeZone; @@ -1687,7 +1687,7 @@ DetermineLocalTimeZone(struct pg_tm *tm) &before_gmtoff, &before_isdst, &boundary, &after_gmtoff, &after_isdst, - global_timezone); + tzp); if (res < 0) goto overflow; /* failure? */ @@ -2282,7 +2282,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, tmp->tm_hour = tm->tm_hour; tmp->tm_min = tm->tm_min; tmp->tm_sec = tm->tm_sec; - *tzp = DetermineLocalTimeZone(tmp); + *tzp = DetermineTimeZoneOffset(tmp, global_timezone); tm->tm_isdst = tmp->tm_isdst; } -- cgit v1.2.3