Update documentation to reflect the fact that we now know exactly what

time zone names we support.
This commit is contained in:
Tom Lane 2004-08-10 00:55:08 +00:00
parent 1ad8aedb5f
commit 97b1ac1aef
4 changed files with 1378 additions and 121 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.146 2004/06/16 01:26:35 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.147 2004/08/10 00:55:02 tgl Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
@ -1668,6 +1668,11 @@ SELECT b, char_length(b) FROM test2;
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
<para>
Refer to <xref linkend="datetime-appendix"> for a list of
time zone names that are recognized for input.
</para>
</sect3> </sect3>
<sect3> <sect3>
@ -1687,9 +1692,11 @@ SELECT b, char_length(b) FROM test2;
<para> <para>
Valid input for the time stamp types consists of a concatenation Valid input for the time stamp types consists of a concatenation
of a date and a time, followed by an optional of a date and a time, followed by an optional time zone,
<literal>AD</literal> or <literal>BC</literal>, followed by an followed by an optional <literal>AD</literal> or <literal>BC</literal>.
optional time zone. Thus (Alternatively, <literal>AD</literal>/<literal>BC</literal> can appear
before the time zone, but this is not the preferred ordering.)
Thus
<programlisting> <programlisting>
1999-01-08 04:05:06 1999-01-08 04:05:06
@ -1798,17 +1805,7 @@ January 8 04:05:06 1999 PST
</indexterm> </indexterm>
<para> <para>
The following <acronym>SQL</acronym>-compatible functions can be <productname>PostgreSQL</productname> supports several
used as date or time values for the corresponding data type:
<literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
<literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
<literal>LOCALTIMESTAMP</literal>. The latter four accept an
optional precision specification. (See also <xref
linkend="functions-datetime-current">.)
</para>
<para>
<productname>PostgreSQL</productname> also supports several
special date/time input values for convenience, as shown in <xref special date/time input values for convenience, as shown in <xref
linkend="datatype-datetime-special-table">. The values linkend="datatype-datetime-special-table">. The values
<literal>infinity</literal> and <literal>-infinity</literal> <literal>infinity</literal> and <literal>-infinity</literal>
@ -1874,6 +1871,18 @@ January 8 04:05:06 1999 PST
</tgroup> </tgroup>
</table> </table>
<para>
The following <acronym>SQL</acronym>-compatible functions can also
be used to obtain the current time value for the corresponding data
type:
<literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
<literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
<literal>LOCALTIMESTAMP</literal>. The latter four accept an
optional precision specification. (See also <xref
linkend="functions-datetime-current">.) Note however that these are
SQL functions and are <emphasis>not</> recognized as data input strings.
</para>
</sect3> </sect3>
</sect2> </sect2>
@ -1985,12 +1994,12 @@ January 8 04:05:06 1999 PST
<para> <para>
<type>interval</type> output looks like the input format, except <type>interval</type> output looks like the input format, except
that units like <literal>century</literal> or that units like <literal>century</literal> or
<literal>wek</literal> are converted to years and days and that <literal>week</literal> are converted to years and days and
<literal>ago</literal> is converted to an appropriate sign. In <literal>ago</literal> is converted to an appropriate sign. In
ISO mode the output looks like ISO mode the output looks like
<programlisting> <programlisting>
<optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>sekunden</> </optional> <optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>seconds</> </optional>
</programlisting> </programlisting>
</para> </para>
@ -2017,19 +2026,13 @@ January 8 04:05:06 1999 PST
Time zones, and time-zone conventions, are influenced by Time zones, and time-zone conventions, are influenced by
political decisions, not just earth geometry. Time zones around the political decisions, not just earth geometry. Time zones around the
world became somewhat standardized during the 1900's, world became somewhat standardized during the 1900's,
but continue to be prone to arbitrary changes. but continue to be prone to arbitrary changes, particularly with
<productname>PostgreSQL</productname> uses your operating respect to daylight-savings rules.
system's underlying features to provide output time-zone <productname>PostgreSQL</productname> currently supports daylight-savings
support, and these systems usually contain information for only rules over the time period 1902 through 2038 (corresponding to the full
the time period 1902 through 2038 (corresponding to the full range of conventional Unix system time). Times outside that range are
range of conventional Unix system time). taken to be in <quote>standard time</> for the selected time zone, no
<type>timestamp with time zone</type> and <type>time with time matter what part of the year they fall in.
zone</type> will use time zone
information only within that year range, and assume that times
outside that range are in <acronym>UTC</acronym>.
But since time zone support is derived from the underlying operating
system time-zone capabilities, it can handle daylight-saving time
and other special behavior.
</para> </para>
<para> <para>
@ -2044,8 +2047,8 @@ January 8 04:05:06 1999 PST
Although the <type>date</type> type Although the <type>date</type> type
does not have an associated time zone, the does not have an associated time zone, the
<type>time</type> type can. <type>time</type> type can.
Time zones in the real world can have no meaning unless Time zones in the real world have little meaning unless
associated with a date as well as a time associated with a date as well as a time,
since the offset may vary through the year with daylight-saving since the offset may vary through the year with daylight-saving
time boundaries. time boundaries.
</para> </para>
@ -2054,8 +2057,8 @@ January 8 04:05:06 1999 PST
<listitem> <listitem>
<para> <para>
The default time zone is specified as a constant numeric offset The default time zone is specified as a constant numeric offset
from <acronym>UTC</>. It is not possible to adapt to daylight-saving from <acronym>UTC</>. It is therefore not possible to adapt to
time when doing date/time arithmetic across daylight-saving time when doing date/time arithmetic across
<acronym>DST</acronym> boundaries. <acronym>DST</acronym> boundaries.
</para> </para>
</listitem> </listitem>
@ -2069,34 +2072,45 @@ January 8 04:05:06 1999 PST
recommend <emphasis>not</emphasis> using the type <type>time with recommend <emphasis>not</emphasis> using the type <type>time with
time zone</type> (though it is supported by time zone</type> (though it is supported by
<productname>PostgreSQL</productname> for legacy applications and <productname>PostgreSQL</productname> for legacy applications and
for compatibility with other <acronym>SQL</acronym> for compliance with the <acronym>SQL</acronym> standard).
implementations). <productname>PostgreSQL</productname> assumes <productname>PostgreSQL</productname> assumes
your local time zone for any type containing only date or time. your local time zone for any type containing only date or time.
</para> </para>
<para> <para>
All dates and times are stored internally in All timezone-aware dates and times are stored internally in
<acronym>UTC</acronym>. Times are converted to local time <acronym>UTC</acronym>. They are converted to local time
on the database server before being sent to the client, in the zone specified by the <xref linkend="guc-timezone"> configuration
hence by default are in the server time zone. parameter before being displayed to the client.
</para> </para>
<para> <para>
There are several ways to select the time zone used by the server: The <xref linkend="guc-timezone"> configuration parameter can
be set in the file <filename>postgresql.conf</>, or in any of the
other standard ways described in <xref linkend="runtime-config">.
There are also several special ways to set it:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
The <envar>TZ</envar> environment variable on the server host If <varname>timezone</> is not specified in
is used by the server as the default time zone, if no other is <filename>postgresql.conf</> nor as a postmaster command-line switch,
specified. the server attempts to use the value of the <envar>TZ</envar>
environment variable as the default time zone. If <envar>TZ</envar>
is not defined or is not any of the time zone names known to
<productname>PostgreSQL</productname>, the server attempts to
determine the operating system's default time zone by checking the
behavior of the C library function <literal>localtime()</>. The
default time zone is selected as the closest match among
<productname>PostgreSQL</productname>'s known time zones.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
The <xref linkend="guc-timezone"> configuration parameter can The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
be set in the file <filename>postgresql.conf</>. sets the time zone for the session. This is an alternative spelling
of <command>SET TIMEZONE TO</> with a more SQL-spec-compatible syntax.
</para> </para>
</listitem> </listitem>
@ -2108,23 +2122,9 @@ January 8 04:05:06 1999 PST
command to the server upon connection. command to the server upon connection.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
sets the time zone for the session.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</para> </para>
<note>
<para>
If an invalid time zone is specified, the time zone becomes
<acronym>UTC</acronym> (on most systems anyway).
</para>
</note>
<para> <para>
Refer to <xref linkend="datetime-appendix"> for a list of Refer to <xref linkend="datetime-appendix"> for a list of
available time zones. available time zones.

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.216 2004/08/04 21:33:40 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.217 2004/08/10 00:55:03 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -5027,7 +5027,7 @@ EXTRACT (<replaceable>field</replaceable> FROM <replaceable>source</replaceable>
<term><literal>century</literal></term> <term><literal>century</literal></term>
<listitem> <listitem>
<para> <para>
The historical definition of a century. The century
</para> </para>
<screen> <screen>
@ -5038,20 +5038,19 @@ SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');
</screen> </screen>
<para> <para>
An historical century is a period of 100 years. The first century starts at 0001-01-01 00:00:00 AD, although
The first century starts at 0001-01-01 00:00:00 AD, although they did not know it at the time. This definition applies to all
they did not know at the time. This definition applies to all Gregorian calendar countries. There is no century number 0,
Gregorian calendar countries. There is no number 0 century, you go from -1 to 1.
you go from -1 to 1.
If you disagree with this, please write your complaint to: If you disagree with this, please write your complaint to:
Pope, Cathedral Saint-Peter of Roma, Vatican. Pope, Cathedral Saint-Peter of Roma, Vatican.
</para> </para>
<para> <para>
Compatibility: if you want the previous postgres version of century, <productname>PostgreSQL</productname> releases before 8.0 did not
just divide the year by 100. Note that with this definition, follow the conventional numbering of centuries, but just returned
century number 0 lasts 200 years. the year field divided by 100.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -5175,7 +5174,7 @@ SELECT EXTRACT(MICROSECONDS FROM TIME '17:12:28.5');
<term><literal>millennium</literal></term> <term><literal>millennium</literal></term>
<listitem> <listitem>
<para> <para>
The conventional historical millennium. The millennium
</para> </para>
<screen> <screen>
@ -5184,8 +5183,14 @@ SELECT EXTRACT(MILLENNIUM FROM TIMESTAMP '2001-02-16 20:38:40');
</screen> </screen>
<para> <para>
Years in the 1900's are in the second millennium. Years in the 1900s are in the second millennium.
The third millennium starts January 1, 2001. The third millennium starts January 1, 2001.
</para>
<para>
<productname>PostgreSQL</productname> releases before 8.0 did not
follow the conventional numbering of millennia, but just returned
the year field divided by 1000.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -5481,6 +5486,11 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
In these expressions, the desired time zone <replaceable>zone</> can be In these expressions, the desired time zone <replaceable>zone</> can be
specified either as a text string (e.g., <literal>'PST'</literal>) specified either as a text string (e.g., <literal>'PST'</literal>)
or as an interval (e.g., <literal>INTERVAL '-08:00'</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-input-table">. (It would be useful
to support the more general names shown in
<xref linkend="datetime-timezone-set-table">, but this is not yet
implemented.)
</para> </para>
<para> <para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.85 2004/08/03 20:32:32 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.86 2004/08/10 00:55:08 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -158,7 +158,7 @@ SELECT setseed(<replaceable>value</replaceable>);
for <literal>SET timezone TO <replaceable>value</></>. The for <literal>SET timezone TO <replaceable>value</></>. The
syntax <literal>SET TIME ZONE</literal> allows special syntax syntax <literal>SET TIME ZONE</literal> allows special syntax
for the time zone specification. Here are examples of valid for the time zone specification. Here are examples of valid
values (but note some are accepted only on some platforms): values:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
@ -169,14 +169,6 @@ SELECT setseed(<replaceable>value</replaceable>);
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><literal>'Portugal'</literal></term>
<listitem>
<para>
The time zone for Portugal.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><literal>'Europe/Rome'</literal></term> <term><literal>'Europe/Rome'</literal></term>
<listitem> <listitem>
@ -216,7 +208,8 @@ SELECT setseed(<replaceable>value</replaceable>);
</variablelist> </variablelist>
See <xref linkend="datatype-datetime"> for more information See <xref linkend="datatype-datetime"> for more information
about time zones. about time zones. Also, <xref linkend="datetime-appendix">
has a list of the recognized names for time zones.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -253,15 +246,16 @@ SET datestyle TO postgres, dmy;
</para> </para>
<para> <para>
Set the time zone for Berkeley, California, using quotes to Set the time zone for Berkeley, California:
preserve the uppercase spelling of the time zone name:
<screen> <screen>
SET TIME ZONE 'PST8PDT'; SET TIME ZONE 'PST8PDT';
SELECT current_timestamp AS today; </screen>
</para>
today <para>
------------------------------- Set the time zone for Italy:
2003-04-29 15:02:01.218622-07 <screen>
SET TIME ZONE 'Europe/Rome';
</screen> </screen>
</para> </para>
</refsect1> </refsect1>