]> begriffs open source - ai-pg/blob - full-docs/txt/datetime-input-rules.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / datetime-input-rules.txt
1
2 B.1. Date/Time Input Interpretation #
3
4    Date/time input strings are decoded using the following procedure.
5     1. Break the input string into tokens and categorize each token as a
6        string, time, time zone, or number.
7          a. If the numeric token contains a colon (:), this is a time
8             string. Include all subsequent digits and colons.
9          b. If the numeric token contains a dash (-), slash (/), or two or
10             more dots (.), this is a date string which might have a text
11             month. If a date token has already been seen, it is instead
12             interpreted as a time zone name (e.g., America/New_York).
13          c. If the token is numeric only, then it is either a single field
14             or an ISO 8601 concatenated date (e.g., 19990113 for January
15             13, 1999) or time (e.g., 141516 for 14:15:16).
16          d. If the token starts with a plus (+) or minus (-), then it is
17             either a numeric time zone or a special field.
18     2. If the token is an alphabetic string, match up with possible
19        strings:
20          a. See if the token matches any known time zone abbreviation.
21             These abbreviations are determined by the configuration
22             settings described in Section B.4.
23          b. If not found, search an internal table to match the token as
24             either a special string (e.g., today), day (e.g., Thursday),
25             month (e.g., January), or noise word (e.g., at, on).
26          c. If still not found, throw an error.
27     3. When the token is a number or number field:
28          a. If there are eight or six digits, and if no other date fields
29             have been previously read, then interpret as a “concatenated
30             date” (e.g., 19990118 or 990118). The interpretation is
31             YYYYMMDD or YYMMDD.
32          b. If the token is three digits and a year has already been read,
33             then interpret as day of year.
34          c. If four or six digits and a year has already been read, then
35             interpret as a time (HHMM or HHMMSS).
36          d. If three or more digits and no date fields have yet been
37             found, interpret as a year (this forces yy-mm-dd ordering of
38             the remaining date fields).
39          e. Otherwise the date field ordering is assumed to follow the
40             DateStyle setting: mm-dd-yy, dd-mm-yy, or yy-mm-dd. Throw an
41             error if a month or day field is found to be out of range.
42     4. If BC has been specified, negate the year and add one for internal
43        storage. (There is no year zero in the Gregorian calendar, so
44        numerically 1 BC becomes year zero.)
45     5. If BC was not specified, and if the year field was two digits in
46        length, then adjust the year to four digits. If the field is less
47        than 70, then add 2000, otherwise add 1900.
48
49 Tip
50        Gregorian years AD 1–99 can be entered by using 4 digits with
51        leading zeros (e.g., 0099 is AD 99).