diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 32f1726402ecb1040ea433f159f84691fdacc121..919e6dc99f212bb0fc8396d18e04c3d490a6e1b2 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -100,15 +100,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm * tm, char **tzn) pg_time_t time = (pg_time_t) _time; struct pg_tm *tx; - /* - * If HasCTZSet is true then we have a brute force time zone specified. Go - * ahead and rotate to the local time zone since we will later bypass any - * calls which adjust the tm fields. - */ - if (HasCTZSet && (tzp != NULL)) - time -= CTimeZone; - - if (!HasCTZSet && tzp != NULL) + if (tzp != NULL) tx = pg_localtime(&time, session_timezone); else tx = pg_gmtime(&time); @@ -126,21 +118,6 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm * tm, char **tzn) if (tzp != NULL) { - /* - * We have a brute force time zone per SQL99? Then use it without - * change since we have already rotated to the time zone. - */ - if (HasCTZSet) - { - *tzp = CTimeZone; - tm->tm_gmtoff = CTimeZone; - tm->tm_isdst = 0; - tm->tm_zone = NULL; - if (tzn != NULL) - *tzn = NULL; - } - else - { *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ /* @@ -161,7 +138,6 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm * tm, char **tzn) errmsg("invalid time zone name: \"%s\"", tm->tm_zone))); } - } } else tm->tm_isdst = -1; diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 94b2a3608a61d53990dffb8a361d7ae5e795370d..c3c71b72810dcccb8dc15c04c6e57b812dde3fc8 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -1498,8 +1498,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) * 0 on success * -1 on out of range * - * If attimezone is NULL, the global timezone (including possibly brute forced - * timezone) will be used. + * If attimezone is NULL, the global timezone setting will be used. */ int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone) @@ -1508,19 +1507,9 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, const char Timestamp time; pg_time_t utime; - /* - * If HasCTZSet is true then we have a brute force time zone specified. Go - * ahead and rotate to the local time zone since we will later bypass any - * calls which adjust the tm fields. - */ - if (attimezone == NULL && HasCTZSet && tzp != NULL) - { -#ifdef HAVE_INT64_TIMESTAMP - dt -= CTimeZone * USECS_PER_SEC; -#else - dt -= CTimeZone; -#endif - } + /* Use session timezone if caller asks for default */ + if (attimezone == NULL) + attimezone = session_timezone; #ifdef HAVE_INT64_TIMESTAMP time = dt; @@ -1589,21 +1578,6 @@ recalc_t: return 0; } - /* - * We have a brute force time zone per SQL99? Then use it without change - * since we have already rotated to the time zone. - */ - if (attimezone == NULL && HasCTZSet) - { - *tzp = CTimeZone; - tm->tm_isdst = 0; - tm->tm_gmtoff = CTimeZone; - tm->tm_zone = NULL; - if (tzn != NULL) - *tzn = NULL; - return 0; - } - /* * If the time falls within the range of pg_time_t, use pg_localtime() to * rotate to the local time zone. @@ -1624,8 +1598,7 @@ recalc_t: utime = (pg_time_t) dt; if ((Timestamp) utime == dt) { - struct pg_tm *tx = pg_localtime(&utime, - attimezone ? attimezone : session_timezone); + struct pg_tm *tx = pg_localtime(&utime, attimezone); tm->tm_year = tx->tm_year + 1900; tm->tm_mon = tx->tm_mon + 1; diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out index 2666deea88bd9838f48f2037378d31bc1b26f8fe..3ed9c8c1a095e939ef8cdd1c050fac307a96cdc5 100644 --- a/src/test/regress/expected/horology.out +++ b/src/test/regress/expected/horology.out @@ -2959,9 +2959,9 @@ SELECT '2012-12-12 12:00 America/New_York'::timestamptz; (1 row) SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ'); - to_char ----------------------- - 2012-12-12 12:00:00 + to_char +---------------------------- + 2012-12-12 12:00:00 -01:30 (1 row) RESET TIME ZONE;