1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

Make EXTRACT(TIMEZONE) and SET/SHOW TIMEZONE follow the SQL convention

for the sign of timezone offsets, ie, positive is east from UTC.  These
were previously out of step with other operations that accept or show
timezones, such as I/O of timestamptz values.
This commit is contained in:
Tom Lane
2003-07-17 00:55:37 +00:00
parent 93236b58e0
commit 764f72dc82
10 changed files with 74 additions and 41 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.81 2003/07/15 19:34:43 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.82 2003/07/17 00:55:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -429,7 +429,8 @@ assign_timezone(const char *value, bool doit, bool interactive)
}
if (doit)
{
CTimeZone = interval->time;
/* Here we change from SQL to Unix sign convention */
CTimeZone = - interval->time;
HasCTZSet = true;
}
pfree(interval);
@ -444,7 +445,8 @@ assign_timezone(const char *value, bool doit, bool interactive)
{
if (doit)
{
CTimeZone = hours * 3600;
/* Here we change from SQL to Unix sign convention */
CTimeZone = - hours * 3600;
HasCTZSet = true;
}
}
@ -557,7 +559,8 @@ assign_timezone(const char *value, bool doit, bool interactive)
return NULL;
if (HasCTZSet)
snprintf(result, sizeof(tzbuf), "%.5f", (double) CTimeZone / 3600.0);
snprintf(result, sizeof(tzbuf), "%.5f",
(double) (-CTimeZone) / 3600.0);
else if (tzbuf[0] == 'T')
strcpy(result, tzbuf + 3);
else
@ -579,7 +582,7 @@ show_timezone(void)
Interval interval;
interval.month = 0;
interval.time = CTimeZone;
interval.time = - CTimeZone;
tzn = DatumGetCString(DirectFunctionCall1(interval_out,
IntervalPGetDatum(&interval)));