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);
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 */
/*
errmsg("invalid time zone name: \"%s\"",
tm->tm_zone)));
}
- }
}
else
tm->tm_isdst = -1;
* 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)
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;
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.
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;