Next: , Previous: Physical constants, Up: Physical Quantities


5.5 Date and time

Dates and times can be represented in Antik with the timepoint class. A timepoint is a specific point in Newtonian time, so includes a date and time, and a timescale (best thought of as a timezone). Timepoints are most conveniently made with the #d reader macro; the default timescale is UTC, and the standard format for specification of timepoints is ISO 8601

     ANTIK-USER> #d2011-08-04T12:00
     2011-08-04 12:00:00.000
     #d2011-08-04T12:00EST
     2011-08-04 17:00:00.000

Other timescales available are UT1, TAI, GPS, and any of the customary time zone abbreviations that define offsets from UTC; these are listed in the variable *timescales*. In order to convert to and from UT1, it is necessary to obtain earth orientation parameters from the US Naval Observatory; if *real-ut1-utc* is nil, then UT1 is taken the same as UTC.

The function read-time will read a timepoint or time interval in ISO8601 format. Timepoints may be read in any format using the function read-timepoint. The default is the ISO8601 format, with a broadened allowance for separators between the components. A day without a specific time will be marked :day-only. The function read-us-date is provided to read US-style dates (month/day/year).

     ANTIK-USER> (read-time "2011-08-04T12:00")
     2011-08-04 12:00:00.000
     ANTIK-USER> (read-time "1999?03/30    % 12-33-45")
     1999-03-30 12:33:45.000
     ANTIK-USER> (read-timepoint "20/12/2011" '(2 1 0)) ; Read a European-style date
     2011-12-20
     ANTIK-USER> (read-us-date "12/20/2000 3:41:12")
     2000-12-20 03:41:12.000
     ANTIK-USER> (read-us-date "12/20/11 3:41:12") ; Two-digit years are acceptable
     2011-12-20 03:41:12.000

Dates are output in ISO8601 format. The function write-us-date can be used to format in US style.

— Class: antik:timepoint

Class precedence list: timepoint, dtspec, standard-object, t

Specification of a point in time, including a scale.

— Variable: antik:*real-ut1-utc*

If nil, ut1 will be taken the same as utc.

— Function: antik:read-time string

Parse the datime or time interval string and create a timepoint object.

— Function: antik:read-timepoint string &optional pos-ymdhms scale

Read a timepoint from a string with specification for the position in the string of each component; pos-ymdhms is a list of year, month, day, hour, minute, and second as sequence numbers for the integers in the string. Scale is the timescale (zone) as a string or symbol. If pos-ymdhms has only three components, or only a date is provided, the timepoint created will be specifed as day-only. The default reads an iso8601 string like 1999-03-30t12:33:45.

— Function: antik:read-us-date string &optional day-only

Read dates and times in customary us format MM/DD/YYYY; times may be included as well if day-only is nil.

— Function: antik:write-us-date datime

Write dates and times in customary us format MM/DD/YYYY.