<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.159 2003/07/15 19:19:55 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.160 2003/07/17 00:55:36 tgl Exp $
PostgreSQL documentation
-->
</screen>
</listitem>
</varlistentry>
-<!--
<varlistentry>
<term><literal>timezone</literal></term>
<listitem>
<para>
- The time zone offset. XXX But in what units?
+ The time zone offset from UTC, measured in seconds. Positive values
+ correspond to time zones east of UTC, negative values to
+ zones west of UTC.
</para>
</listitem>
</varlistentry>
--->
<varlistentry>
<term><literal>timezone_hour</literal></term>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.78 2003/07/15 19:19:56 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.79 2003/07/17 00:55:36 tgl Exp $
PostgreSQL documentation
-->
</listitem>
</varlistentry>
<varlistentry>
- <term><literal>7</literal></term>
+ <term><literal>-7</literal></term>
<listitem>
<para>
The time zone 7 hours west from UTC (equivalent
- to PDT). Negative values are east from UTC.
+ to PDT). Positive values are east from UTC.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><literal>INTERVAL '08:00' HOUR TO MINUTE</literal></term>
+ <term><literal>INTERVAL '-08:00' HOUR TO MINUTE</literal></term>
<listitem>
<para>
The time zone 8 hours west from UTC (equivalent
<listitem>
<para>
Set the time zone to your local time zone (the one that
- your operating system defaults to).
+ the server's operating system defaults to).
</para>
</listitem>
</varlistentry>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.197 2003/07/15 19:19:55 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.198 2003/07/17 00:55:36 tgl Exp $
-->
<appendix id="release">
worries about funny characters.
-->
<literallayout><![CDATA[
+EXTRACT(TIMEZONE) and SET/SHOW TIMEZONE now follow SQL sign convention
+ (positive = east of UTC)
Output of SHOW DATESTYLE is now in the same format accepted by SET DATESTYLE
PL/Python is now an untrusted language, and is renamed to 'plpythonu'
Dollar sign ($) is no longer allowed in operator names
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
}
if (doit)
{
- CTimeZone = interval->time;
+ /* Here we change from SQL to Unix sign convention */
+ CTimeZone = - interval->time;
HasCTZSet = true;
}
pfree(interval);
{
if (doit)
{
- CTimeZone = hours * 3600;
+ /* Here we change from SQL to Unix sign convention */
+ CTimeZone = - hours * 3600;
HasCTZSet = true;
}
}
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
Interval interval;
interval.month = 0;
- interval.time = CTimeZone;
+ interval.time = - CTimeZone;
tzn = DatumGetCString(DirectFunctionCall1(interval_out,
IntervalPGetDatum(&interval)));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.83 2003/06/16 18:56:45 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.84 2003/07/17 00:55:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
switch (val)
{
case DTK_TZ:
- result = tz;
+ result = -tz;
break;
case DTK_TZ_MINUTE:
- result = tz / 60;
- TMODULO(result, dummy, 60e0);
+ result = -tz;
+ result /= 60;
+ FMODULO(result, dummy, 60e0);
break;
case DTK_TZ_HOUR:
- dummy = tz;
- TMODULO(dummy, result, 3600e0);
+ dummy = -tz;
+ FMODULO(dummy, result, 3600e0);
break;
case DTK_MICROSEC:
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.108 2003/05/12 23:08:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.109 2003/07/17 00:55:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static void
reltime2tm(RelativeTime time, struct tm * tm)
{
- TMODULO(time, tm->tm_year, 31557600);
- TMODULO(time, tm->tm_mon, 2592000);
- TMODULO(time, tm->tm_mday, 86400);
- TMODULO(time, tm->tm_hour, 3600);
- TMODULO(time, tm->tm_min, 60);
- TMODULO(time, tm->tm_sec, 1);
+ double dtime = time;
+
+ FMODULO(dtime, tm->tm_year, 31557600);
+ FMODULO(dtime, tm->tm_mon, 2592000);
+ FMODULO(dtime, tm->tm_mday, 86400);
+ FMODULO(dtime, tm->tm_hour, 3600);
+ FMODULO(dtime, tm->tm_min, 60);
+ FMODULO(dtime, tm->tm_sec, 1);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.85 2003/07/04 18:21:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.86 2003/07/17 00:55:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
switch (val)
{
case DTK_TZ:
- result = tz;
+ result = -tz;
break;
case DTK_TZ_MINUTE:
- result = tz / 60;
- TMODULO(result, dummy, 60e0);
+ result = -tz;
+ result /= 60;
+ FMODULO(result, dummy, 60e0);
break;
case DTK_TZ_HOUR:
- dummy = tz;
- TMODULO(dummy, result, 3600e0);
+ dummy = -tz;
+ FMODULO(dummy, result, 3600e0);
break;
case DTK_MICROSEC:
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.125 2003/06/27 19:08:38 tgl Exp $
+ * $Id: miscadmin.h,v 1.126 2003/07/17 00:55:37 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
* EuroDates if client prefers dates interpreted and written w/European conventions.
*
* HasCTZSet is true if user has set timezone as a numeric offset from UTC.
- * If so, CTimeZone is the timezone offset in seconds.
+ * If so, CTimeZone is the timezone offset in seconds (using the Unix-ish
+ * sign convention, ie, positive offset is west of UTC, rather than the
+ * SQL-ish convention that positive is east of UTC).
*/
#define MAXTZLEN 10 /* max TZ name len, not counting tr. null */
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: datetime.h,v 1.39 2003/05/18 01:06:26 tgl Exp $
+ * $Id: datetime.h,v 1.40 2003/07/17 00:55:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
} datetkn;
-/* TMODULO()
+/* FMODULO()
* Macro to replace modf(), which is broken on some platforms.
* t = input and remainder
* q = integer part
* u = divisor
*/
+#define FMODULO(t,q,u) \
+do { \
+ q = ((t < 0) ? ceil(t / u): floor(t / u)); \
+ if (q != 0) t -= rint(q * u); \
+} while(0)
+
+/* TMODULO()
+ * Like FMODULO(), but work on the timestamp datatype (either int64 or float8).
+ * We assume that int64 follows the C99 semantics for division (negative
+ * quotients truncate towards zero).
+ */
#ifdef HAVE_INT64_TIMESTAMP
#define TMODULO(t,q,u) \
do { \
#else
#define TMODULO(t,q,u) \
do { \
- q = ((t < 0)? ceil(t / u): floor(t / u)); \
+ q = ((t < 0) ? ceil(t / u): floor(t / u)); \
if (q != 0) t -= rint(q * u); \
} while(0)
#endif
} datetkn;
-/* TMODULO()
+/* FMODULO()
* Macro to replace modf(), which is broken on some platforms.
* t = input and remainder
* q = integer part
* u = divisor
*/
+#define FMODULO(t,q,u) \
+do { \
+ q = ((t < 0) ? ceil(t / u): floor(t / u)); \
+ if (q != 0) t -= rint(q * u); \
+} while(0)
+
+/* TMODULO()
+ * Like FMODULO(), but work on the timestamp datatype (either int64 or float8).
+ * We assume that int64 follows the C99 semantics for division (negative
+ * quotients truncate towards zero).
+ */
#ifdef HAVE_INT64_TIMESTAMP
#define TMODULO(t,q,u) \
do { \
#else
#define TMODULO(t,q,u) \
do { \
- q = ((t < 0)? ceil(t / u): floor(t / u)); \
+ q = ((t < 0) ? ceil(t / u): floor(t / u)); \
if (q != 0) t -= rint(q * u); \
} while(0)
#endif