]> granicus.if.org Git - postgresql/blob - doc/src/sgml/datetime.sgml
Add the Brazilian time zone abbreviations BRT, BRST, FNT, FNST.
[postgresql] / doc / src / sgml / datetime.sgml
1 <!--
2 $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.33 2003/08/25 23:30:25 tgl Exp $
3 -->
4
5  <appendix id="datetime-appendix">
6   <title>Date/Time Support</title>
7
8   <para>
9    <productname>PostgreSQL</productname> uses an internal heuristic
10    parser for all date/time input support. Dates and times are input as
11    strings, and are broken up into distinct fields with a preliminary
12    determination of what kind of information may be in the
13    field. Each field is interpreted and either assigned a numeric
14    value, ignored, or rejected.
15    The parser contains internal lookup tables for all textual fields,
16    including months, days of the week, and time
17    zones.
18   </para>
19
20   <para>
21    This appendix includes information on the content of these
22    lookup tables and describes the steps used by the parser to decode
23    dates and times.
24   </para>
25
26   <sect1>
27    <title>Date/Time Input Interpretation</title>
28
29    <para>
30     The date/time type inputs are all decoded using the following procedure.
31    </para>
32
33    <procedure>
34     <step>
35      <para>
36       Break the input string into tokens and categorize each token as
37       a string, time, time zone, or number.
38      </para>
39
40      <substeps>
41       <step>
42        <para>
43         If the numeric token contains a colon (<literal>:</>), this is
44         a time string. Include all subsequent digits and colons.
45        </para>
46       </step>
47
48       <step>
49        <para>
50         If the numeric token contains a dash (<literal>-</>), slash
51         (<literal>/</>), or two or more dots (<literal>.</>), this is
52         a date string which may have a text month.
53        </para>
54       </step>
55
56       <step>
57        <para>
58         If the token is numeric only, then it is either a single field
59         or an ISO 8601 concatenated date (e.g.,
60         <literal>19990113</literal> for January 13, 1999) or time
61         (e.g., <literal>141516</literal> for 14:15:16).
62        </para>
63       </step>
64
65       <step>
66        <para>
67         If the token starts with a plus (<literal>+</>) or minus
68         (<literal>-</>), then it is either a time zone or a special
69         field.
70        </para>
71       </step>
72      </substeps>
73     </step>
74
75     <step>
76      <para>
77       If the token is a text string, match up with possible strings.
78      </para>
79      
80      <substeps>
81       <step>
82        <para>
83         Do a binary-search table lookup for the token
84         as either a special string (e.g., <literal>today</literal>),
85         day (e.g., <literal>Thursday</literal>),
86         month (e.g., <literal>January</literal>),
87         or noise word (e.g., <literal>at</literal>, <literal>on</literal>).
88        </para>
89
90        <para>
91         Set field values and bit mask for fields.
92         For example, set year, month, day for <literal>today</literal>,
93         and additionally hour, minute, second for <literal>now</literal>.
94        </para>
95       </step>
96       
97       <step>
98        <para>
99         If not found, do a similar binary-search table lookup to match
100         the token with a time zone.
101        </para>
102       </step>
103
104       <step>
105        <para>
106         If still not found, throw an error.
107        </para>
108       </step>
109      </substeps>
110     </step>
111     
112     <step>
113      <para>
114       When the token is a number or number field:
115      </para>
116
117      <substeps>
118       <step>
119        <para>
120         If there are eight or six digits,
121         and if no other date fields have been previously read, then interpret 
122         as a <quote>concatenated date</quote> (e.g.,
123         <literal>19990118</literal> or <literal>990118</literal>).
124         The interpretation is <literal>YYYYMMDD</> or <literal>YYMMDD</>.
125        </para>
126       </step>
127
128       <step>
129        <para>
130         If the token is three digits
131         and a year has already been read, then interpret as day of year.
132        </para>
133       </step>
134       
135       <step>
136        <para>
137         If four or six digits and a year has already been read, then
138         interpret as a time (<literal>HHMM</> or <literal>HHMMSS</>).
139        </para>
140       </step>
141
142       <step>
143        <para>
144         If three or more digits and no date fields have yet been found,
145         interpret as a year (this forces yy-mm-dd ordering of the remaining
146         date fields).
147        </para>
148       </step>
149
150       <step>
151        <para>
152         Otherwise the date field ordering is assumed to follow the
153         <varname>DateStyle</> setting: mm-dd-yy, dd-mm-yy, or yy-mm-dd.
154         Throw an error if a month or day field is found to be out of range.
155        </para>
156       </step>
157      </substeps>
158     </step>
159
160     <step>
161      <para>
162       If BC has been specified, negate the year and add one for
163       internal storage.  (There is no year zero in the Gregorian
164       calendar, so numerically 1 BC becomes year
165       zero.)
166      </para>
167     </step>
168
169     <step>
170      <para>
171       If BC was not specified, and if the year field was two digits in length, then
172       adjust the year to four digits. If the field is less than 70, then add 2000,
173       otherwise add 1900.
174
175       <tip>
176        <para>
177         Gregorian years AD 1-99 may be entered by using 4 digits with leading
178         zeros (e.g., <literal>0099</> is AD 99). Previous versions of
179         <productname>PostgreSQL</productname> accepted years with three
180         digits and with single digits, but as of version 7.0 the rules have
181         been tightened up to reduce the possibility of ambiguity.
182        </para>
183       </tip>
184      </para>
185     </step>
186    </procedure>
187   </sect1>
188
189
190   <sect1 id="datetime-keywords">
191    <title>Date/Time Key Words</title>
192
193    <para>
194     <xref linkend="datetime-month-table"> shows the tokens that are
195     permissible as abbreviations for the names of the month.
196    </para>
197
198     <table id="datetime-month-table">
199      <title>Month Abbreviations</title>
200      <tgroup cols="2">
201       <thead>
202        <row>
203         <entry>Month</entry>
204         <entry>Abbreviations</entry>
205        </row>
206       </thead>
207       <tbody>
208        <row>
209         <entry>April</entry>
210         <entry>Apr</entry>
211        </row>
212        <row>
213         <entry>August</entry>
214         <entry>Aug</entry>
215        </row>
216        <row>
217         <entry>December</entry>
218         <entry>Dec</entry>
219        </row>
220        <row>
221         <entry>February</entry>
222         <entry>Feb</entry>
223        </row>
224        <row>
225         <entry>January</entry>
226         <entry>Jan</entry>
227        </row>
228        <row>
229         <entry>July</entry>
230         <entry>Jul</entry>
231        </row>
232        <row>
233         <entry>June</entry>
234         <entry>Jun</entry>
235        </row>
236        <row>
237         <entry>March</entry>
238         <entry>Mar</entry>
239        </row>
240        <row>
241         <entry>November</entry>
242         <entry>Nov</entry>
243        </row>
244        <row>
245         <entry>October</entry>
246         <entry>Oct</entry>
247        </row>
248        <row>
249         <entry>September</entry>
250         <entry>Sep, Sept</entry>
251        </row>
252       </tbody>
253      </tgroup>
254     </table>
255
256     <note>
257      <para>
258       The month May has no explicit abbreviation, for obvious reasons.
259      </para>
260     </note>
261
262     <para>
263      <xref linkend="datetime-dow-table"> shows the tokens that are
264      permissible as abbreviations for the names of the days of the
265      week.
266     </para>
267
268      <table id="datetime-dow-table">
269       <title>Day of the Week Abbreviations</title>
270       <tgroup cols="2">
271        <thead>
272         <row>
273          <entry>Day</entry>
274          <entry>Abbreviation</entry>
275         </row>
276        </thead>
277        <tbody>
278         <row>
279          <entry>Sunday</entry>
280          <entry>Sun</entry>
281         </row>
282         <row>
283          <entry>Monday</entry>
284          <entry>Mon</entry>
285         </row>
286         <row>
287          <entry>Tuesday</entry>
288          <entry>Tue, Tues</entry>
289         </row>
290         <row>
291          <entry>Wednesday</entry>
292          <entry>Wed, Weds</entry>
293         </row>
294         <row>
295          <entry>Thursday</entry>
296          <entry>Thu, Thur, Thurs</entry>
297         </row>
298         <row>
299          <entry>Friday</entry>
300          <entry>Fri</entry>
301         </row>
302         <row>
303          <entry>Saturday</entry>
304          <entry>Sat</entry>
305         </row>
306        </tbody>
307       </tgroup>
308      </table>
309
310    <para>
311     <xref linkend="datetime-mod-table"> shows the tokens that serve
312     various modifier purposes.
313    </para>
314
315     <table id="datetime-mod-table">
316      <title>Date/Time Field Modifiers</title>
317      <tgroup cols="2">
318       <thead>
319        <row>
320         <entry>Identifier</entry>
321         <entry>Description</entry>
322        </row>
323       </thead>
324       <tbody>
325        <row>
326         <entry><literal>ABSTIME</literal></entry>
327         <entry>Key word ignored</entry>
328        </row>
329        <row>
330         <entry><literal>AM</literal></entry>
331         <entry>Time is before 12:00</entry>
332        </row>
333        <row>
334         <entry><literal>AT</literal></entry>
335         <entry>Key word ignored</entry>
336        </row>
337        <row>
338         <entry><literal>JULIAN</>, <literal>JD</>, <literal>J</></entry>
339         <entry>Next field is Julian Day</entry>
340        </row>
341        <row>
342         <entry><literal>ON</literal></entry>
343         <entry>Key word ignored</entry>
344        </row>
345        <row>
346         <entry><literal>PM</literal></entry>
347         <entry>Time is on or after after 12:00</entry>
348        </row>
349        <row>
350         <entry><literal>T</literal></entry>
351         <entry>Next field is time</entry>
352        </row>
353       </tbody>
354      </tgroup>
355     </table>
356
357    <para>
358     The key word <literal>ABSTIME</literal> is ignored for historical
359     reasons: In very old releases of
360     <productname>PostgreSQL</productname>, invalid values of type <type>abstime</type>
361     were emitted as <literal>Invalid Abstime</literal>. This is no
362     longer the case however and this key word will likely be dropped in
363     a future release.
364    </para>
365
366    <indexterm>
367     <primary>time zones</primary>
368    </indexterm>
369
370    <para>
371     <xref linkend="datetime-timezone-table"> shows the time zone
372     abbreviations recognized by <productname>PostgreSQL</productname>.
373     <productname>PostgreSQL</productname> contains internal tabular
374     information for time zone decoding, since there is no standard
375     operating system interface to provide access to general,
376     cross-time zone information. The underlying operating system
377     <emphasis>is</emphasis> used to provide time zone information for
378     <emphasis>output</emphasis>, however.
379    </para>
380
381    <para>
382     The table is organized by time zone offset from <acronym>UTC</>,
383     rather than alphabetically.  This is intended to facilitate
384     matching local usage with recognized abbreviations for cases where
385     these might differ.
386    </para>
387
388     <table id="datetime-timezone-table">
389      <title>Time Zone Abbreviations</title>
390      <tgroup cols="3">
391       <thead>
392        <row>
393         <entry>Time Zone</entry>
394         <entry>Offset from UTC</entry>
395         <entry>Description</entry>
396        </row>
397       </thead>
398       <tbody>
399        <row>
400         <entry>NZDT</entry>
401         <entry>+13:00</entry>
402         <entry>New Zealand Daylight-Saving Time</entry>
403        </row>
404        <row>
405         <entry>IDLE</entry>
406         <entry>+12:00</entry>
407         <entry>International Date Line, East</entry>
408        </row>
409        <row>
410         <entry>NZST</entry>
411         <entry>+12:00</entry>
412         <entry>New Zealand Standard Time</entry>
413        </row>
414        <row>
415         <entry>NZT</entry>
416         <entry>+12:00</entry>
417         <entry>New Zealand Time</entry>
418        </row>
419        <row>
420         <entry>AESST</entry>
421         <entry>+11:00</entry>
422         <entry>Australia Eastern Summer Standard Time</entry>
423        </row>
424        <row>
425         <entry>ACSST</entry>
426         <entry>+10:30</entry>
427         <entry>Central Australia Summer Standard Time</entry>
428        </row>
429        <row>
430         <entry>CADT</entry>
431         <entry>+10:30</entry>
432         <entry>Central Australia Daylight-Saving Time</entry>
433        </row>
434        <row>
435         <entry>SADT</entry>
436         <entry>+10:30</entry>
437         <entry>South Australian Daylight-Saving Time</entry>
438        </row>
439        <row>
440         <entry>AEST</entry>
441         <entry>+10:00</entry>
442         <entry>Australia Eastern Standard Time</entry>
443        </row>
444        <row>
445         <entry>EAST</entry>
446         <entry>+10:00</entry>
447         <entry>East Australian Standard Time</entry>
448        </row>
449        <row>
450         <entry>GST</entry>
451         <entry>+10:00</entry>
452         <entry>Guam Standard Time, Russia zone 9</entry>
453        </row>
454        <row>
455         <entry>LIGT</entry>
456         <entry>+10:00</entry>
457         <entry>Melbourne, Australia</entry>
458        </row>
459        <row>
460         <entry>SAST</entry>
461         <entry>+09:30</entry>
462         <entry>South Australia Standard Time</entry>
463        </row>
464        <row>
465         <entry>CAST</entry>
466         <entry>+09:30</entry>
467         <entry>Central Australia Standard Time</entry>
468        </row>
469        <row>
470         <entry>AWSST</entry>
471         <entry>+09:00</entry>
472         <entry>Australia Western Summer Standard Time</entry>
473        </row>
474        <row>
475         <entry>JST</entry>
476         <entry>+09:00</entry>
477         <entry>Japan Standard Time, Russia zone 8</entry>
478        </row>
479        <row>
480         <entry>KST</entry>
481         <entry>+09:00</entry>
482         <entry>Korea Standard Time</entry>
483        </row>
484        <row>
485         <entry>MHT</entry>
486         <entry>+09:00</entry>
487         <entry>Kwajalein Time</entry>
488        </row>
489        <row>
490         <entry>WDT</entry>
491         <entry>+09:00</entry>
492         <entry>West Australian Daylight-Saving Time</entry>
493        </row>
494        <row>
495         <entry>MT</entry>
496         <entry>+08:30</entry>
497         <entry>Moluccas Time</entry>
498        </row>
499        <row>
500         <entry>AWST</entry>
501         <entry>+08:00</entry>
502         <entry>Australia Western Standard Time</entry>
503        </row>
504        <row>
505         <entry>CCT</entry>
506         <entry>+08:00</entry>
507         <entry>China Coastal Time</entry>
508        </row>
509        <row>
510         <entry>WADT</entry>
511         <entry>+08:00</entry>
512         <entry>West Australian Daylight-Saving Time</entry>
513        </row>
514        <row>
515         <entry>WST</entry>
516         <entry>+08:00</entry>
517         <entry>West Australian Standard Time</entry>
518        </row>
519        <row>
520         <entry>JT</entry>
521         <entry>+07:30</entry>
522         <entry>Java Time</entry>
523        </row>
524        <row>
525         <entry>ALMST</entry>
526         <entry>+07:00</entry>
527         <entry>Almaty Summer Time</entry>
528        </row>
529        <row>
530         <entry>WAST</entry>
531         <entry>+07:00</entry>
532         <entry>West Australian Standard Time</entry>
533        </row>
534        <row>
535         <entry>CXT</entry>
536         <entry>+07:00</entry>
537         <entry>Christmas (Island) Time</entry>
538        </row>
539        <row>
540         <entry>MMT</entry>
541         <entry>+06:30</entry>
542         <entry>Myanmar Time</entry>
543        </row>
544        <row>
545         <entry>ALMT</entry>
546         <entry>+06:00</entry>
547         <entry>Almaty Time</entry>
548        </row>
549        <row>
550         <entry>MAWT</entry>
551         <entry>+06:00</entry>
552         <entry>Mawson (Antarctica) Time</entry>
553        </row>
554        <row>
555         <entry>IOT</entry>
556         <entry>+05:00</entry>
557         <entry>Indian Chagos Time</entry>
558        </row>
559        <row>
560         <entry>MVT</entry>
561         <entry>+05:00</entry>
562         <entry>Maldives Island Time</entry>
563        </row>
564        <row>
565         <entry>TFT</entry>
566         <entry>+05:00</entry>
567         <entry>Kerguelen Time</entry>
568        </row>
569        <row>
570         <entry>AFT</entry>
571         <entry>+04:30</entry>
572         <entry>Afganistan Time</entry>
573        </row>
574        <row>
575         <entry>EAST</entry>
576         <entry>+04:00</entry>
577         <entry>Antananarivo Summer Time</entry>
578        </row>
579        <row>
580         <entry>MUT</entry>
581         <entry>+04:00</entry>
582         <entry>Mauritius Island Time</entry>
583        </row>
584        <row>
585         <entry>RET</entry>
586         <entry>+04:00</entry>
587         <entry>Reunion Island Time</entry>
588        </row>
589        <row>
590         <entry>SCT</entry>
591         <entry>+04:00</entry>
592         <entry>Mahe Island Time</entry>
593        </row>
594        <row>
595         <entry>IRT, IT</entry>
596         <entry>+03:30</entry>
597         <entry>Iran Time</entry>
598        </row>
599        <row>
600         <entry>EAT</entry>
601         <entry>+03:00</entry>
602         <entry>Antananarivo, Comoro Time</entry>
603        </row>
604        <row>
605         <entry>BT</entry>
606         <entry>+03:00</entry>
607         <entry>Baghdad Time</entry>
608        </row>
609        <row>
610         <entry>EETDST</entry>
611         <entry>+03:00</entry>
612         <entry>Eastern Europe Daylight-Saving Time</entry>
613        </row>
614        <row>
615         <entry>HMT</entry>
616         <entry>+03:00</entry>
617         <entry>Hellas Mediterranean Time (?)</entry>
618        </row>
619        <row>
620         <entry>BDST</entry>
621         <entry>+02:00</entry>
622         <entry>British Double Standard Time</entry>
623        </row>
624        <row>
625         <entry>CEST</entry>
626         <entry>+02:00</entry>
627         <entry>Central European Summer Time</entry>
628        </row>
629        <row>
630         <entry>CETDST</entry>
631         <entry>+02:00</entry>
632         <entry>Central European Daylight-Saving Time</entry>
633        </row>
634        <row>
635         <entry>EET</entry>
636         <entry>+02:00</entry>
637         <entry>Eastern European Time, Russia zone 1</entry>
638        </row>
639        <row>
640         <entry>FWT</entry>
641         <entry>+02:00</entry>
642         <entry>French Winter Time</entry>
643        </row>
644        <row>
645         <entry>IST</entry>
646         <entry>+02:00</entry>
647         <entry>Israel Standard Time</entry>
648        </row>
649        <row>
650         <entry>MEST</entry>
651         <entry>+02:00</entry>
652         <entry>Middle European Summer Time</entry>
653        </row>
654        <row>
655         <entry>METDST</entry>
656         <entry>+02:00</entry>
657         <entry>Middle Europe Daylight-Saving Time</entry>
658        </row>
659        <row>
660         <entry>SST</entry>
661         <entry>+02:00</entry>
662         <entry>Swedish Summer Time</entry>
663        </row>
664        <row>
665         <entry>BST</entry>
666         <entry>+01:00</entry>
667         <entry>British Summer Time</entry>
668        </row>
669        <row>
670         <entry>CET</entry>
671         <entry>+01:00</entry>
672         <entry>Central European Time</entry>
673        </row>
674        <row>
675         <entry>DNT</entry>
676         <entry>+01:00</entry>
677         <entry><foreignphrase>Dansk Normal Tid</foreignphrase></entry>
678        </row>
679        <row>
680         <entry>FST</entry>
681         <entry>+01:00</entry>
682         <entry>French Summer Time</entry>
683        </row>
684        <row>
685         <entry>MET</entry>
686         <entry>+01:00</entry>
687         <entry>Middle European Time</entry>
688        </row>
689        <row>
690         <entry>MEWT</entry>
691         <entry>+01:00</entry>
692         <entry>Middle European Winter Time</entry>
693        </row>
694        <row>
695         <entry>MEZ</entry>
696         <entry>+01:00</entry>
697         <entry><foreignphrase>Mitteleuropäische Zeit</></entry>
698        </row>
699        <row>
700         <entry>NOR</entry>
701         <entry>+01:00</entry>
702         <entry>Norway Standard Time</entry>
703        </row>
704        <row>
705         <entry>SET</entry>
706         <entry>+01:00</entry>
707         <entry>Seychelles Time</entry>
708        </row>
709        <row>
710         <entry>SWT</entry>
711         <entry>+01:00</entry>
712         <entry>Swedish Winter Time</entry>
713        </row>
714        <row>
715         <entry>WETDST</entry>
716         <entry>+01:00</entry>
717         <entry>Western European Daylight-Saving Time</entry>
718        </row>
719        <row>
720         <entry>GMT</entry>
721         <entry>00:00</entry>
722         <entry>Greenwich Mean Time</entry>
723        </row>
724        <row>
725         <entry>UT</entry>
726         <entry>00:00</entry>
727         <entry>Universal Time</entry>
728        </row>
729        <row>
730         <entry>UTC</entry>
731         <entry>00:00</entry>
732         <entry>Universal Coordinated Time</entry>
733        </row>
734        <row>
735         <entry>Z</entry>
736         <entry>00:00</entry>
737         <entry>Same as UTC</entry>
738        </row>
739        <row>
740         <entry>ZULU</entry>
741         <entry>00:00</entry>
742         <entry>Same as UTC</entry>
743        </row>
744        <row>
745         <entry>WET</entry>
746         <entry>00:00</entry>
747         <entry>Western European Time</entry>
748        </row>
749        <row>
750         <entry>WAT</entry>
751         <entry>-01:00</entry>
752         <entry>West Africa Time</entry>
753        </row>
754        <row>
755         <entry>FNST</entry>
756         <entry>-01:00</entry>
757         <entry>Fernando de Noronha Summer Time</entry>
758        </row>
759        <row>
760         <entry>FNT</entry>
761         <entry>-02:00</entry>
762         <entry>Fernando de Noronha Time</entry>
763        </row>
764        <row>
765         <entry>BRST</entry>
766         <entry>-02:00</entry>
767         <entry>Brasilia Summer Time</entry>
768        </row>
769        <row>
770         <entry>NDT</entry>
771         <entry>-02:30</entry>
772         <entry>Newfoundland Daylight-Saving Time</entry>
773        </row>
774        <row>
775         <entry>ADT</entry>
776         <entry>-03:00</entry>
777         <entry>Atlantic Daylight-Saving Time</entry>
778        </row>
779        <row>
780         <entry>AWT</entry>
781         <entry>-03:00</entry>
782         <entry>(unknown)</entry>
783        </row>
784        <row>
785         <entry>BRT</entry>
786         <entry>-03:00</entry>
787         <entry>Brasilia Time</entry>
788        </row>
789        <row>
790         <entry>NFT</entry>
791         <entry>-03:30</entry>
792         <entry>Newfoundland Standard Time</entry>
793        </row>
794        <row>
795         <entry>NST</entry>
796         <entry>-03:30</entry>
797         <entry>Newfoundland Standard Time</entry>
798        </row>
799        <row>
800         <entry>AST</entry>
801         <entry>-04:00</entry>
802         <entry>Atlantic Standard Time (Canada)</entry>
803        </row>
804        <row>
805         <entry>ACST</entry>
806         <entry>-04:00</entry>
807         <entry>Atlantic/Porto Acre Summer Time</entry>
808        </row>
809        <row>
810         <entry>EDT</entry>
811         <entry>-04:00</entry>
812         <entry>Eastern Daylight-Saving Time</entry>
813        </row>
814        <!--
815       <row>
816       <entry>ZP4</entry>
817       <entry>-04:00</entry>
818       <entry>GMT +4 hours</entry>
819       </row>
820        -->
821        <row>
822         <entry>ACT</entry>
823         <entry>-05:00</entry>
824         <entry>Atlantic/Porto Acre Standard Time</entry>
825        </row>
826        <row>
827         <entry>CDT</entry>
828         <entry>-05:00</entry>
829         <entry>Central Daylight-Saving Time</entry>
830        </row>
831        <row>
832         <entry>EST</entry>
833         <entry>-05:00</entry>
834         <entry>Eastern Standard Time</entry>
835        </row>
836        <!--
837       <row>
838       <entry>ZP5</entry>
839       <entry>-05:00</entry>
840       <entry>GMT +5  hours</entry>
841       </row>
842        -->
843        <row>
844         <entry>CST</entry>
845         <entry>-06:00</entry>
846         <entry>Central Standard Time</entry>
847        </row>
848        <row>
849         <entry>MDT</entry>
850         <entry>-06:00</entry>
851         <entry>Mountain Daylight-Saving Time</entry>
852        </row>
853        <!--
854       <row>
855       <entry>ZP6</entry>
856       <entry>-06:00</entry>
857       <entry>GMT +6  hours</entry>
858       </row>
859        -->
860        <row>
861         <entry>MST</entry>
862         <entry>-07:00</entry>
863         <entry>Mountain Standard Time</entry>
864        </row>
865        <row>
866         <entry>PDT</entry>
867         <entry>-07:00</entry>
868         <entry>Pacific Daylight-Saving Time</entry>
869        </row>
870        <row>
871         <entry>AKDT</entry>
872         <entry>-08:00</entry>
873         <entry>Alaska Daylight-Saving Time</entry>
874        </row>
875        <row>
876         <entry>PST</entry>
877         <entry>-08:00</entry>
878         <entry>Pacific Standard Time</entry>
879        </row>
880        <row>
881         <entry>YDT</entry>
882         <entry>-08:00</entry>
883         <entry>Yukon Daylight-Saving Time</entry>
884        </row>
885        <row>
886         <entry>AKST</entry>
887         <entry>-09:00</entry>
888         <entry>Alaska Standard Time</entry>
889        </row>
890        <row>
891         <entry>HDT</entry>
892         <entry>-09:00</entry>
893         <entry>Hawaii/Alaska Daylight-Saving Time</entry>
894        </row>
895        <row>
896         <entry>YST</entry>
897         <entry>-09:00</entry>
898         <entry>Yukon Standard Time</entry>
899        </row>
900        <row>
901         <entry>MART</entry>
902         <entry>-09:30</entry>
903         <entry>Marquesas Time</entry>
904        </row>
905        <row>
906         <entry>AHST</entry>
907         <entry>-10:00</entry>
908         <entry>Alaska/Hawaii Standard Time</entry>
909        </row>
910        <row>
911         <entry>HST</entry>
912         <entry>-10:00</entry>
913         <entry>Hawaii Standard Time</entry>
914        </row>
915        <row>
916         <entry>CAT</entry>
917         <entry>-10:00</entry>
918         <entry>Central Alaska Time</entry>
919        </row>
920        <row>
921         <entry>NT</entry>
922         <entry>-11:00</entry>
923         <entry>Nome Time</entry>
924        </row>
925        <row>
926         <entry>IDLW</entry>
927         <entry>-12:00</entry>
928         <entry>International Date Line, West</entry>
929        </row>
930       </tbody>
931      </tgroup>
932     </table>
933
934   <formalpara>
935    <title>Australian Time Zones</title>
936
937    <para>
938     There are three naming conflicts between Australian time zone
939     names and time zone names commonly used in North and South America:
940     <literal>ACST</literal>, <literal>CST</literal>, and
941     <literal>EST</literal>.  If the run-time option
942     <varname>australian_timezones</varname> is set to true then
943     <literal>ACST</literal>, <literal>CST</literal>,
944     <literal>EST</literal>, and <literal>SAT</literal> are interpreted
945     as Australian time zone names, as shown in <xref
946     linkend="datetime-oztz-table">. If it is false (which is the
947     default), then <literal>ACST</literal>, <literal>CST</literal>,
948     and <literal>EST</literal> are taken as American time zone names,
949     and <literal>SAT</literal> is interpreted as a noise word
950     indicating Saturday.
951    </para>
952   </formalpara>
953
954     <table id="datetime-oztz-table">
955      <title>Australian Time Zone Abbreviations</title>
956      <tgroup cols="3">
957       <thead>
958        <row>
959         <entry>Time Zone</entry>
960         <entry>Offset from UTC</entry>
961         <entry>Description</entry>
962        </row>
963       </thead>
964       <tbody>
965        <row>
966         <entry>ACST</entry>
967         <entry>+09:30</entry>
968         <entry>Central Australia Standard Time</entry>
969        </row>
970        <row>
971         <entry>CST</entry>
972         <entry>+10:30</entry>
973         <entry>Australian Central Standard Time</entry>
974        </row>
975        <row>
976         <entry>EST</entry>
977         <entry>+10:00</entry>
978         <entry>Australian Eastern Standard Time</entry>
979        </row>
980        <row>
981         <entry>SAT</entry>
982         <entry>+09:30</entry>
983         <entry>South Australian Standard Time</entry>
984        </row>
985       </tbody>
986      </tgroup>
987     </table>
988
989   </sect1>
990
991   <sect1 id="datetime-units-history">
992   <title>History of Units</title>
993
994   <para>
995    The Julian Date was invented by the French scholar
996    Joseph Justus Scaliger (1540-1609)
997    and probably takes its name from the Scaliger's father,
998    the Italian scholar Julius Caesar Scaliger (1484-1558).
999    Astronomers have used the Julian period to assign a unique number to
1000    every day since 1 January 4713 BC. This is the so-called Julian Date
1001    (JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC
1002    to noon UTC on 2 January 4713 BC.
1003   </para>
1004
1005    <para>
1006    The <quote>Julian Date</quote> is different from the <quote>Julian
1007    Calendar</quote>.  The Julian calendar
1008    was introduced by Julius Caesar in 45 BC. It was in common use
1009    until the 1582, when countries started changing to the Gregorian
1010    calendar.  In the Julian calendar, the tropical year is
1011    approximated as 365 1/4 days = 365.25 days. This gives an error of
1012    about 1 day in 128 years.
1013   </para>
1014
1015   <para>   
1016    The accumulating calendar error prompted
1017    Pope Gregory XIII to reform the calendar in accordance with
1018    instructions from the Council of Trent.
1019    In the Gregorian calendar, the tropical year is approximated as
1020    365 + 97 / 400 days = 365.2425 days. Thus it takes approximately 3300
1021    years for the tropical year to shift one day with respect to the
1022    Gregorian calendar.
1023   </para>
1024
1025   <para>
1026    The approximation 365+97/400 is achieved by having 97 leap years
1027    every 400 years, using the following rules:
1028
1029    <simplelist>
1030     <member>
1031      Every year divisible by 4 is a leap year.
1032     </member>
1033     <member>
1034      However, every year divisible by 100 is not a leap year.
1035     </member>
1036     <member>
1037      However, every year divisible by 400 is a leap year after all.
1038     </member>
1039    </simplelist>
1040
1041    So, 1700, 1800, 1900, 2100, and 2200 are not leap years. But 1600,
1042    2000, and 2400 are leap years.
1043
1044    By contrast, in the older Julian calendar only years divisible by 4 are leap years.
1045   </para>
1046
1047   <para>
1048    The papal bull of February 1582 decreed that 10 days should be dropped
1049    from October 1582 so that 15 October should follow immediately after
1050    4 October.
1051    This was observed in Italy, Poland, Portugal, and Spain. Other Catholic
1052    countries followed shortly after, but Protestant countries were
1053    reluctant to change, and the Greek orthodox countries didn't change
1054    until the start of the 20th century.
1055
1056    The reform was observed by Great Britain and Dominions (including what is
1057    now the USA) in 1752.
1058    Thus 2 September 1752 was followed by 14 September 1752.
1059
1060    This is why Unix systems have the <command>cal</command> program
1061    produce the following:
1062
1063 <screen>
1064 $ <userinput>cal 9 1752</userinput>
1065    September 1752
1066  S  M Tu  W Th  F  S
1067        1  2 14 15 16
1068 17 18 19 20 21 22 23
1069 24 25 26 27 28 29 30
1070 </screen>
1071   </para>
1072
1073    <note>
1074     <para>
1075      The SQL standard states that <quote>Within the definition of a
1076      <quote>datetime literal</quote>, the <quote>datetime
1077      value</quote>s are constrained by the natural rules for dates and
1078      times according to the Gregorian calendar</quote>.  Dates between
1079      1752-09-03 and 1752-09-13, although eliminated in some countries
1080      by Papal fiat, conform to <quote>natural rules</quote> and are
1081      hence valid dates.
1082     </para>
1083    </note>
1084
1085   <para>
1086    Different calendars have been developed in various parts of the
1087    world, many predating the Gregorian system.
1088
1089    For example,
1090    the beginnings of the Chinese calendar can be traced back to the 14th
1091    century BC. Legend has it that the Emperor Huangdi invented the
1092    calendar in 2637 BC.
1093    
1094    The People's Republic of China uses the Gregorian calendar
1095    for civil purposes. The Chinese calendar is used for determining
1096    festivals.
1097   </para>
1098  </sect1>
1099 </appendix>
1100
1101 <!-- Keep this comment at the end of the file
1102 Local variables:
1103 mode:sgml
1104 sgml-omittag:nil
1105 sgml-shorttag:t
1106 sgml-minimize-attributes:nil
1107 sgml-always-quote-attributes:t
1108 sgml-indent-step:1
1109 sgml-indent-data:t
1110 sgml-parent-document:nil
1111 sgml-default-dtd-file:"./reference.ced"
1112 sgml-exposed-tags:nil
1113 sgml-local-catalogs:("/usr/lib/sgml/catalog")
1114 sgml-local-ecat-files:nil
1115 End:
1116 -->