datetime.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:20k
- <!--
- $Header: /usr/local/cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.4 1999/06/23 06:17:51 thomas Exp $
- Date/time details
- $Log: datetime.sgml,v $
- Revision 2.4 1999/06/23 06:17:51 thomas
- Clarify input/output timezone information.
- Add detail on exact interpretation of "concatenated date"
- for various lengths.
- Revision 2.3 1999/05/26 17:30:28 thomas
- Add chapters on CVS access, MVCC, SQL theory to the docs.
- Add an appendix with more details on date/time attributes and handling.
- Update most references to Postgres version numbers to 6.5,
- *except* for the porting list which will require a report
- from a successful installation to be updated.
- Revision 2.2 1999/05/22 02:27:23 thomas
- Finish initial markup of cvs.sgml, and include it in the programmer's guide
- and the integrated doc. Clean up other markup.
- -->
- <appendix label="UG1" id="datetime-appendix">
- <title id="datetime-appendix-title">Date/Time Support</title>
- <sect1>
- <title>Time Zones</title>
- <para>
- <productname>Postgres</productname> must have internal tabular
- information for time zone decoding, since there is no *nix standard
- system interface to provide access to general, cross-timezone
- information. The underlying OS <emphasis>is</emphasis> used to
- provide time zone information for <emphasis>output</emphasis>.
- <table tocentry="1">
- <title><productname>Postgres</productname> Recognized Time Zones</title>
- <titleabbrev>Time Zones</titleabbrev>
- <tgroup cols="3">
- <thead>
- <row>
- <entry>Time Zone</entry>
- <entry>Offset from UTC</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>NZDT</entry>
- <entry>+13:00</entry>
- <entry>New Zealand Daylight Time</entry>
- </row>
- <row>
- <entry>IDLE</entry>
- <entry>+12:00</entry>
- <entry>International Date Line, East</entry>
- </row>
- <row>
- <entry>NZST</entry>
- <entry>+12:00</entry>
- <entry>New Zealand Std Time</entry>
- </row>
- <row>
- <entry>NZT</entry>
- <entry>+12:00</entry>
- <entry>New Zealand Time</entry>
- </row>
- <row>
- <entry>AESST</entry>
- <entry>+11:00 </entry>
- <entry>Australia Eastern Summer Std Time</entry>
- </row>
- <row>
- <entry>ACSST</entry>
- <entry>+10:30 </entry>
- <entry>Central Australia Summer Std Time</entry>
- </row>
- <row>
- <entry>CADT</entry>
- <entry>+10:30 </entry>
- <entry>Central Australia Daylight Savings Time</entry>
- </row>
- <row>
- <entry>SADT</entry>
- <entry>+10:30</entry>
- <entry>South Australian Daylight Time</entry>
- </row>
- <row>
- <entry>AEST</entry>
- <entry>+10:00 </entry>
- <entry>Australia Eastern Std Time</entry>
- </row>
- <row>
- <entry>EAST</entry>
- <entry>+10:00 </entry>
- <entry>East Australian Std Time</entry>
- </row>
- <row>
- <entry>GST</entry>
- <entry>+10:00</entry>
- <entry>Guam Std Time, USSR Zone 9</entry>
- </row>
- <row>
- <entry>LIGT</entry>
- <entry>+10:00</entry>
- <entry>Melbourne, Australia</entry>
- </row>
- <row>
- <entry>ACST</entry>
- <entry>+09:30 </entry>
- <entry>Central Australia Std Time</entry>
- </row>
- <row>
- <entry>CAST</entry>
- <entry>+09:30 </entry>
- <entry>Central Australia Std Time</entry>
- </row>
- <row>
- <entry>SAT</entry>
- <entry>+9:30</entry>
- <entry>South Australian Std Time</entry>
- </row>
- <row>
- <entry>AWSST</entry>
- <entry>+9:00 </entry>
- <entry>Australia Western Summer Std Time</entry>
- </row>
- <row>
- <entry>JST</entry>
- <entry>+9:00</entry>
- <entry>Japan Std Time,USSR Zone 8</entry>
- </row>
- <row>
- <entry>KST</entry>
- <entry>+9:00</entry>
- <entry>Korea Standard Time</entry>
- </row>
- <row>
- <entry>WDT</entry>
- <entry>+9:00</entry>
- <entry>West Australian Daylight Time</entry>
- </row>
- <row>
- <entry>MT</entry>
- <entry>+8:30</entry>
- <entry>Moluccas Time</entry>
- </row>
- <row>
- <entry>AWST</entry>
- <entry>+8:00 </entry>
- <entry>Australia Western Std Time</entry>
- </row>
- <row>
- <entry>CCT</entry>
- <entry>+8:00 </entry>
- <entry>China Coastal Time</entry>
- </row>
- <row>
- <entry>WADT</entry>
- <entry>+8:00</entry>
- <entry>West Australian Daylight Time</entry>
- </row>
- <row>
- <entry>WST</entry>
- <entry>+8:00</entry>
- <entry>West Australian Std Time</entry>
- </row>
- <row>
- <entry>JT</entry>
- <entry>+7:30</entry>
- <entry>Java Time</entry>
- </row>
- <row>
- <entry>WAST</entry>
- <entry>+7:00</entry>
- <entry>West Australian Std Time</entry>
- </row>
- <row>
- <entry>IT</entry>
- <entry>+3:30</entry>
- <entry>Iran Time</entry>
- </row>
- <row>
- <entry>BT</entry>
- <entry>+3:00 </entry>
- <entry>Baghdad Time</entry>
- </row>
- <row>
- <entry>EETDST</entry>
- <entry>+3:00 </entry>
- <entry>Eastern Europe Daylight Savings Time</entry>
- </row>
- <row>
- <entry>CETDST</entry>
- <entry>+2:00 </entry>
- <entry>Central European Daylight Savings Time</entry>
- </row>
- <row>
- <entry>EET</entry>
- <entry>+2:00 </entry>
- <entry>Eastern Europe, USSR Zone 1</entry>
- </row>
- <row>
- <entry>FWT</entry>
- <entry>+2:00</entry>
- <entry>French Winter Time</entry>
- </row>
- <row>
- <entry>IST</entry>
- <entry>+2:00</entry>
- <entry>Israel Std Time</entry>
- </row>
- <row>
- <entry>MEST</entry>
- <entry>+2:00</entry>
- <entry>Middle Europe Summer Time</entry>
- </row>
- <row>
- <entry>METDST</entry>
- <entry>+2:00</entry>
- <entry>Middle Europe Daylight Time</entry>
- </row>
- <row>
- <entry>SST</entry>
- <entry>+2:00</entry>
- <entry>Swedish Summer Time</entry>
- </row>
- <row>
- <entry>BST</entry>
- <entry>+1:00 </entry>
- <entry>British Summer Time</entry>
- </row>
- <row>
- <entry>CET</entry>
- <entry>+1:00 </entry>
- <entry>Central European Time</entry>
- </row>
- <row>
- <entry>DNT</entry>
- <entry>+1:00 </entry>
- <entry>Dansk Normal Tid</entry>
- </row>
- <row>
- <entry>DST</entry>
- <entry>+1:00 </entry>
- <entry>Dansk Standard Time (?)</entry>
- </row>
- <row>
- <entry>FST</entry>
- <entry>+1:00 </entry>
- <entry>French Summer Time</entry>
- </row>
- <row>
- <entry>MET</entry>
- <entry>+1:00</entry>
- <entry>Middle Europe Time</entry>
- </row>
- <row>
- <entry>MEWT</entry>
- <entry>+1:00</entry>
- <entry>Middle Europe Winter Time</entry>
- </row>
- <row>
- <entry>MEZ</entry>
- <entry>+1:00</entry>
- <entry>Middle Europe Zone</entry>
- </row>
- <row>
- <entry>NOR</entry>
- <entry>+1:00</entry>
- <entry>Norway Standard Time</entry>
- </row>
- <row>
- <entry>SET</entry>
- <entry>+1:00</entry>
- <entry>Seychelles Time</entry>
- </row>
- <row>
- <entry>SWT</entry>
- <entry>+1:00</entry>
- <entry>Swedish Winter Time</entry>
- </row>
- <row>
- <entry>WETDST</entry>
- <entry>+1:00</entry>
- <entry>Western Europe Daylight Savings Time</entry>
- </row>
- <row>
- <entry>GMT</entry>
- <entry>0:00</entry>
- <entry>Greenwish Mean Time</entry>
- </row>
- <row>
- <entry>WET</entry>
- <entry>0:00</entry>
- <entry>Western Europe</entry>
- </row>
- <row>
- <entry>WAT</entry>
- <entry>-1:00</entry>
- <entry>West Africa Time</entry>
- </row>
- <row>
- <entry>NDT</entry>
- <entry>-2:30</entry>
- <entry>Newfoundland Daylight Time</entry>
- </row>
- <row>
- <entry>ADT</entry>
- <entry>-03:00 </entry>
- <entry>Atlantic Daylight Time</entry>
- </row>
- <row>
- <entry>NFT</entry>
- <entry>-3:30</entry>
- <entry>Newfoundland Standard Time</entry>
- </row>
- <row>
- <entry>NST</entry>
- <entry>-3:30</entry>
- <entry>Newfoundland Standard Time</entry>
- </row>
- <row>
- <entry>AST</entry>
- <entry>-4:00 </entry>
- <entry>Atlantic Std Time (Canada)</entry>
- </row>
- <row>
- <entry>EDT</entry>
- <entry>-4:00 </entry>
- <entry>Eastern Daylight Time</entry>
- </row>
- <row>
- <entry>ZP4</entry>
- <entry>-4:00</entry>
- <entry>GMT +4 hours</entry>
- </row>
- <row>
- <entry>CDT</entry>
- <entry>-5:00 </entry>
- <entry>Central Daylight Time</entry>
- </row>
- <row>
- <entry>EST</entry>
- <entry>-5:00 </entry>
- <entry>Eastern Standard Time</entry>
- </row>
- <row>
- <entry>ZP5</entry>
- <entry>-5:00</entry>
- <entry>GMT +5 hours</entry>
- </row>
- <row>
- <entry>CST</entry>
- <entry>-6:00 </entry>
- <entry>Central Std Time</entry>
- </row>
- <row>
- <entry>MDT</entry>
- <entry>-6:00</entry>
- <entry>Mountain Daylight Time</entry>
- </row>
- <row>
- <entry>ZP6</entry>
- <entry>-6:00</entry>
- <entry>GMT +6 hours</entry>
- </row>
- <row>
- <entry>MST</entry>
- <entry>-7:00</entry>
- <entry>Mountain Standard Time</entry>
- </row>
- <row>
- <entry>PDT</entry>
- <entry>-7:00</entry>
- <entry>Pacific Daylight Time</entry>
- </row>
- <row>
- <entry>PST</entry>
- <entry>-8:00</entry>
- <entry>Pacific Std Time</entry>
- </row>
- <row>
- <entry>YDT</entry>
- <entry>-8:00</entry>
- <entry>Yukon Daylight Time</entry>
- </row>
- <row>
- <entry>HDT</entry>
- <entry>-9:00</entry>
- <entry>Hawaii/Alaska Daylight Time</entry>
- </row>
- <row>
- <entry>YST</entry>
- <entry>-9:00</entry>
- <entry>Yukon Standard Time</entry>
- </row>
- <row>
- <entry>AHST</entry>
- <entry>-10:00 </entry>
- <entry>Alaska-Hawaii Std Time</entry>
- </row>
- <row>
- <entry>CAT</entry>
- <entry>-10:00 </entry>
- <entry>Central Alaska Time</entry>
- </row>
- <row>
- <entry>NT</entry>
- <entry>-11:00</entry>
- <entry>Nome Time</entry>
- </row>
- <row>
- <entry>IDLW</entry>
- <entry>-12:00</entry>
- <entry>International Date Line, West</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <note>
- <para>
- If the compiler option USE_AUSTRALIAN_RULES is set
- then <literal>EST</literal> refers to Australia Eastern Std Time,
- which has an offset of +10:00 hours from UTC.
- </para>
- </note>
- </para>
- <para>
- Australian time zones and their naming variants
- account for fully one quarter of all time zones in the
- <productname>Postgres</productname> time zone lookup table.
- </para>
- <procedure>
- <title>Date/Time Input Interpretation</title>
- <para>
- The date/time types are all decoded using a common set of routines.
- </para>
- <step>
- <para>
- Break the input string into tokens and categorize each token as
- a string, time, time zone, or number.
- </para>
- <substeps>
- <step>
- <para>
- If the token contains a colon (":"), this is a time string.
- </para>
- </step>
- <step>
- <para>
- If the token contains a dash ("-"), slash ("/"), or dot ("."),
- this is a date string which may have a text month.
- </para>
- </step>
- <step>
- <para>
- If the token is numeric only, then it is either a single field
- or an ISO-8601 concatenated date (e.g. "19990113" for January 13, 1999)
- or time (e.g. 141516 for 14:15:16).
- </para>
- </step>
- <step>
- <para>
- If the token starts with a plus ("+") or minus ("-"),
- then it is either a time zone or a special field.
- </para>
- </step>
- </substeps>
- </step>
- <step>
- <para>
- If the token is a text string, match up with possible strings.
- </para>
-
- <substeps>
- <step>
- <para>
- Do a binary-search table lookup for the token
- as either a special string (e.g. <literal>today</literal>),
- day (e.g. <literal>Thursday</literal>),
- month (e.g. <literal>January</literal>), or noise word (e.g. <literal>on</literal>).
- </para>
- <para>
- Set field values and bit mask for fields.
- For example, set year, month, day for <literal>today</literal>, and additionally
- hour, minute, second for <literal>now</literal>.
- </para>
- </step>
-
- <step>
- <para>
- If not found, do a similar binary-search table lookup to match
- the token with a time zone.
- </para>
- </step>
- <step>
- <para>
- If not found, throw an error.
- </para>
- </step>
- </substeps>
- </step>
-
- <step>
- <para>
- The token is a number or number field.
- </para>
- <substeps>
- <step>
- <para>
- If there are more than 4 digits,
- and if no other date fields have been previously read, then interpret
- as a "concatenated date" (e.g. <literal>19990118</literal>). 8
- and 6 digits are interpreted as year, month, and day, while 7
- and 5 digits are interpreted as year, day of year.
- </para>
- </step>
- <step>
- <para>
- If the token is three digits
- and a year has already been decoded, then interpret as day of year.
- </para>
- </step>
-
- <step>
- <para>
- If longer than two digits, then interpret as a year.
- </para>
- </step>
- <step>
- <para>
- If in European date mode, and if the day field has not yet been read,
- and if the value is less than or equal to 31, then interpret as a day.
- </para>
- </step>
- <step>
- <para>
- If in non-European (US) date mode, and if the month field has not yet been read,
- and if the value is less than or equal to 12, then interpret as a month.
- </para>
- </step>
- <step>
- <para>
- If the day field has not yet been read,
- and if the value is less than or equal to 31, then interpret as a month.
- </para>
- </step>
- <step>
- <para>
- If the month field has not yet been read,
- and if the value is less than or equal to 12, then interpret as a month.
- </para>
- </step>
- <step>
- <para>
- Otherwise, interpret as a year.
- </para>
- </step>
- </substeps>
- </step>
- <step>
- <para>
- If BC has been specified, negate the year and offset by one for
- internal storage
- (there is no year zero in the Gregorian calendar, so numerically
- 1BC becomes year zero).
- </para>
- </step>
- <step>
- <para>
- If BC was not specified, and if the year field was two digits in length, then
- adjust the year to 4 digits. If the field was less than 70, then add 2000;
- otherwise, add 1900.
- <tip>
- <para>
- Gregorian years 1-99AD may be entered by using 4 digits with leading
- zeros (e.g. 0099 is 99AD). Three digits are also accepted as a
- year under most circumstances, though depending on position the
- numeric string may
- be interpreted as doy instead.
- </para>
- </tip>
- </para>
- </step>
- </procedure>
- </sect1>
- <sect1>
- <title>History</title>
- <note>
- <para>
- Contributed by
- <ulink url="jose@sferacarta.com">Jos