<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.268 2005/07/20 16:42:29 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.269 2005/07/22 21:16:14 momjian Exp $
PostgreSQL documentation
-->
<literal><type>timestamp without time zone</type> AT TIME ZONE <replaceable>zone</></literal>
</entry>
<entry><type>timestamp with time zone</type></entry>
- <entry>Convert local time in given time zone to UTC</entry>
+ <entry>Treat given timestamp <emphasis>without time zone</> as located in the specified time zone</entry>
</row>
<row>
<literal><type>timestamp with time zone</type> AT TIME ZONE <replaceable>zone</></literal>
</entry>
<entry><type>timestamp without time zone</type></entry>
- <entry>Convert UTC to local time in given time zone</entry>
+ <entry>Convert given timestamp <emphasis>with time zone</> to the new time zone</entry>
</row>
<row>
<literal><type>time with time zone</type> AT TIME ZONE <replaceable>zone</></literal>
</entry>
<entry><type>time with time zone</type></entry>
- <entry>Convert local time across time zones</entry>
+ <entry>Convert given time <emphasis>with time zone</> to the new time zone</entry>
</row>
</tbody>
</tgroup>
specified either as a text string (e.g., <literal>'PST'</literal>)
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
In the text case, the available zone names are those shown in
- <xref linkend="datetime-timezone-set-table">.
+ <xref linkend="datetime-timezone-set-table">. The time zone can
+ also be implied using the default time zone for that session.
</para>
<para>
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
</screen>
- The first example takes a zone-less time stamp and interprets it as MST time
- (UTC-7) to produce a UTC time stamp, which is then rotated to PST (UTC-8)
- for display. The second example takes a time stamp specified in EST
- (UTC-5) and converts it to local time in MST (UTC-7).
+ The first example takes a time stamp without time zone and interprets it as MST time
+ (UTC-7), which is then converted to PST (UTC-8) for display. The second example takes
+ a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
</para>
<para>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.141 2005/07/22 19:00:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.142 2005/07/22 21:16:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
/* add offset to go from J2000 back to standard Julian date */
- date +=POSTGRES_EPOCH_JDATE;
+ date += POSTGRES_EPOCH_JDATE;
/* Julian day routine does not work for negative Julian days */
if (date <0 || date >(Timestamp) INT_MAX)
return -1;
date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - POSTGRES_EPOCH_JDATE;
-
time = time2t(tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
+
#ifdef HAVE_INT64_TIMESTAMP
*result = date * USECS_PER_DAY + time;
/* check for major overflow */
result = palloc(len);
VARATT_SIZEP(result) = len;
- memmove(VARDATA(result), str, (len - VARHDRSZ));
+ memmove(VARDATA(result), str, len - VARHDRSZ);
pfree(str);
sp = VARDATA(str);
dp = dstr;
- for (i = 0; i < (VARSIZE(str) - VARHDRSZ); i++)
+ for (i = 0; i < VARSIZE(str) - VARHDRSZ; i++)
*dp++ = *sp++;
*dp = '\0';
str = DatumGetCString(DirectFunctionCall1(timestamptz_out, timestamp));
- len = (strlen(str) + VARHDRSZ);
+ len = strlen(str) + VARHDRSZ;
result = palloc(len);
VARATT_SIZEP(result) = len;
- memmove(VARDATA(result), str, (len - VARHDRSZ));
+ memmove(VARDATA(result), str, len - VARHDRSZ);
pfree(str);
sp = VARDATA(str);
dp = dstr;
- for (i = 0; i < (VARSIZE(str) - VARHDRSZ); i++)
+ for (i = 0; i < VARSIZE(str) - VARHDRSZ; i++)
*dp++ = *sp++;
*dp = '\0';
str = DatumGetCString(DirectFunctionCall1(interval_out,
IntervalPGetDatum(interval)));
- len = (strlen(str) + VARHDRSZ);
+ len = strlen(str) + VARHDRSZ;
result = palloc(len);
case DTK_MILLISEC:
#ifdef HAVE_INT64_TIMESTAMP
- fsec = ((fsec / 1000) * 1000);
+ fsec = (fsec / 1000) * 1000;
#else
fsec = rint(fsec * 1000) / 1000;
#endif
case DTK_MILLISEC:
#ifdef HAVE_INT64_TIMESTAMP
- fsec = ((fsec / 1000) * 1000);
+ fsec = (fsec / 1000) * 1000;
#else
fsec = rint(fsec * 1000) / 1000;
#endif
{
text *zone = PG_GETARG_TEXT_P(0);
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
- Timestamp result;
+ TimestampTz result;
int tz;
pg_tz *tzp;
char tzname[TZ_STRLEN_MAX+1];
tzname)));
PG_RETURN_NULL();
}
- PG_RETURN_TIMESTAMPTZ(timestamp2timestamptz(result));
+ PG_RETURN_TIMESTAMPTZ(result);
}
/* timestamp_izone()