Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 97b1ac1

Browse files
committed
Update documentation to reflect the fact that we now know exactly what
time zone names we support.
1 parent 1ad8aed commit 97b1ac1

File tree

4 files changed

+1379
-122
lines changed

4 files changed

+1379
-122
lines changed

doc/src/sgml/datatype.sgml

+60-60
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.146 2004/06/16 01:26:35 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.147 2004/08/10 00:55:02 tgl Exp $
33
-->
44

55
<chapter id="datatype">
@@ -1668,6 +1668,11 @@ SELECT b, char_length(b) FROM test2;
16681668
</tbody>
16691669
</tgroup>
16701670
</table>
1671+
1672+
<para>
1673+
Refer to <xref linkend="datetime-appendix"> for a list of
1674+
time zone names that are recognized for input.
1675+
</para>
16711676
</sect3>
16721677

16731678
<sect3>
@@ -1687,9 +1692,11 @@ SELECT b, char_length(b) FROM test2;
16871692

16881693
<para>
16891694
Valid input for the time stamp types consists of a concatenation
1690-
of a date and a time, followed by an optional
1691-
<literal>AD</literal> or <literal>BC</literal>, followed by an
1692-
optional time zone. Thus
1695+
of a date and a time, followed by an optional time zone,
1696+
followed by an optional <literal>AD</literal> or <literal>BC</literal>.
1697+
(Alternatively, <literal>AD</literal>/<literal>BC</literal> can appear
1698+
before the time zone, but this is not the preferred ordering.)
1699+
Thus
16931700

16941701
<programlisting>
16951702
1999-01-08 04:05:06
@@ -1798,17 +1805,7 @@ January 8 04:05:06 1999 PST
17981805
</indexterm>
17991806

18001807
<para>
1801-
The following <acronym>SQL</acronym>-compatible functions can be
1802-
used as date or time values for the corresponding data type:
1803-
<literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
1804-
<literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
1805-
<literal>LOCALTIMESTAMP</literal>. The latter four accept an
1806-
optional precision specification. (See also <xref
1807-
linkend="functions-datetime-current">.)
1808-
</para>
1809-
1810-
<para>
1811-
<productname>PostgreSQL</productname> also supports several
1808+
<productname>PostgreSQL</productname> supports several
18121809
special date/time input values for convenience, as shown in <xref
18131810
linkend="datatype-datetime-special-table">. The values
18141811
<literal>infinity</literal> and <literal>-infinity</literal>
@@ -1874,6 +1871,18 @@ January 8 04:05:06 1999 PST
18741871
</tgroup>
18751872
</table>
18761873

1874+
<para>
1875+
The following <acronym>SQL</acronym>-compatible functions can also
1876+
be used to obtain the current time value for the corresponding data
1877+
type:
1878+
<literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
1879+
<literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
1880+
<literal>LOCALTIMESTAMP</literal>. The latter four accept an
1881+
optional precision specification. (See also <xref
1882+
linkend="functions-datetime-current">.) Note however that these are
1883+
SQL functions and are <emphasis>not</> recognized as data input strings.
1884+
</para>
1885+
18771886
</sect3>
18781887
</sect2>
18791888

@@ -1985,12 +1994,12 @@ January 8 04:05:06 1999 PST
19851994
<para>
19861995
<type>interval</type> output looks like the input format, except
19871996
that units like <literal>century</literal> or
1988-
<literal>wek</literal> are converted to years and days and that
1997+
<literal>week</literal> are converted to years and days and
19891998
<literal>ago</literal> is converted to an appropriate sign. In
19901999
ISO mode the output looks like
19912000

19922001
<programlisting>
1993-
<optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>sekunden</> </optional>
2002+
<optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>seconds</> </optional>
19942003
</programlisting>
19952004
</para>
19962005

@@ -2017,19 +2026,13 @@ January 8 04:05:06 1999 PST
20172026
Time zones, and time-zone conventions, are influenced by
20182027
political decisions, not just earth geometry. Time zones around the
20192028
world became somewhat standardized during the 1900's,
2020-
but continue to be prone to arbitrary changes.
2021-
<productname>PostgreSQL</productname> uses your operating
2022-
system's underlying features to provide output time-zone
2023-
support, and these systems usually contain information for only
2024-
the time period 1902 through 2038 (corresponding to the full
2025-
range of conventional Unix system time).
2026-
<type>timestamp with time zone</type> and <type>time with time
2027-
zone</type> will use time zone
2028-
information only within that year range, and assume that times
2029-
outside that range are in <acronym>UTC</acronym>.
2030-
But since time zone support is derived from the underlying operating
2031-
system time-zone capabilities, it can handle daylight-saving time
2032-
and other special behavior.
2029+
but continue to be prone to arbitrary changes, particularly with
2030+
respect to daylight-savings rules.
2031+
<productname>PostgreSQL</productname> currently supports daylight-savings
2032+
rules over the time period 1902 through 2038 (corresponding to the full
2033+
range of conventional Unix system time). Times outside that range are
2034+
taken to be in <quote>standard time</> for the selected time zone, no
2035+
matter what part of the year they fall in.
20332036
</para>
20342037

20352038
<para>
@@ -2044,8 +2047,8 @@ January 8 04:05:06 1999 PST
20442047
Although the <type>date</type> type
20452048
does not have an associated time zone, the
20462049
<type>time</type> type can.
2047-
Time zones in the real world can have no meaning unless
2048-
associated with a date as well as a time
2050+
Time zones in the real world have little meaning unless
2051+
associated with a date as well as a time,
20492052
since the offset may vary through the year with daylight-saving
20502053
time boundaries.
20512054
</para>
@@ -2054,8 +2057,8 @@ January 8 04:05:06 1999 PST
20542057
<listitem>
20552058
<para>
20562059
The default time zone is specified as a constant numeric offset
2057-
from <acronym>UTC</>. It is not possible to adapt to daylight-saving
2058-
time when doing date/time arithmetic across
2060+
from <acronym>UTC</>. It is therefore not possible to adapt to
2061+
daylight-saving time when doing date/time arithmetic across
20592062
<acronym>DST</acronym> boundaries.
20602063
</para>
20612064
</listitem>
@@ -2069,34 +2072,45 @@ January 8 04:05:06 1999 PST
20692072
recommend <emphasis>not</emphasis> using the type <type>time with
20702073
time zone</type> (though it is supported by
20712074
<productname>PostgreSQL</productname> for legacy applications and
2072-
for compatibility with other <acronym>SQL</acronym>
2073-
implementations). <productname>PostgreSQL</productname> assumes
2075+
for compliance with the <acronym>SQL</acronym> standard).
2076+
<productname>PostgreSQL</productname> assumes
20742077
your local time zone for any type containing only date or time.
20752078
</para>
20762079

20772080
<para>
2078-
All dates and times are stored internally in
2079-
<acronym>UTC</acronym>. Times are converted to local time
2080-
on the database server before being sent to the client,
2081-
hence by default are in the server time zone.
2081+
All timezone-aware dates and times are stored internally in
2082+
<acronym>UTC</acronym>. They are converted to local time
2083+
in the zone specified by the <xref linkend="guc-timezone"> configuration
2084+
parameter before being displayed to the client.
20822085
</para>
20832086

20842087
<para>
2085-
There are several ways to select the time zone used by the server:
2088+
The <xref linkend="guc-timezone"> configuration parameter can
2089+
be set in the file <filename>postgresql.conf</>, or in any of the
2090+
other standard ways described in <xref linkend="runtime-config">.
2091+
There are also several special ways to set it:
20862092

20872093
<itemizedlist>
20882094
<listitem>
20892095
<para>
2090-
The <envar>TZ</envar> environment variable on the server host
2091-
is used by the server as the default time zone, if no other is
2092-
specified.
2096+
If <varname>timezone</> is not specified in
2097+
<filename>postgresql.conf</> nor as a postmaster command-line switch,
2098+
the server attempts to use the value of the <envar>TZ</envar>
2099+
environment variable as the default time zone. If <envar>TZ</envar>
2100+
is not defined or is not any of the time zone names known to
2101+
<productname>PostgreSQL</productname>, the server attempts to
2102+
determine the operating system's default time zone by checking the
2103+
behavior of the C library function <literal>localtime()</>. The
2104+
default time zone is selected as the closest match among
2105+
<productname>PostgreSQL</productname>'s known time zones.
20932106
</para>
20942107
</listitem>
20952108

20962109
<listitem>
20972110
<para>
2098-
The <xref linkend="guc-timezone"> configuration parameter can
2099-
be set in the file <filename>postgresql.conf</>.
2111+
The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
2112+
sets the time zone for the session. This is an alternative spelling
2113+
of <command>SET TIMEZONE TO</> with a more SQL-spec-compatible syntax.
21002114
</para>
21012115
</listitem>
21022116

@@ -2108,23 +2122,9 @@ January 8 04:05:06 1999 PST
21082122
command to the server upon connection.
21092123
</para>
21102124
</listitem>
2111-
2112-
<listitem>
2113-
<para>
2114-
The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
2115-
sets the time zone for the session.
2116-
</para>
2117-
</listitem>
21182125
</itemizedlist>
21192126
</para>
21202127

2121-
<note>
2122-
<para>
2123-
If an invalid time zone is specified, the time zone becomes
2124-
<acronym>UTC</acronym> (on most systems anyway).
2125-
</para>
2126-
</note>
2127-
21282128
<para>
21292129
Refer to <xref linkend="datetime-appendix"> for a list of
21302130
available time zones.

0 commit comments

Comments
 (0)