calc: Date Conversions

 
 8.5.1 Date Conversions
 ----------------------
 
 The ‘t D’ (‘calc-date’) [‘date’] command converts a date form into a
 number, measured in days since Jan 1, 1 AD.  The result will be an
 integer if DATE is a pure date form, or a fraction or float if DATE is a
 date/time form.  Or, if its argument is a number, it converts this
 number into a date form.
 
    With a numeric prefix argument, ‘t D’ takes that many objects (up to
 six) from the top of the stack and interprets them in one of the
 following ways:
 
    The ‘date(YEAR, MONTH, DAY)’ function builds a pure date form out of
 the specified year, month, and day, which must all be integers.  YEAR is
 a year number, such as 1991 (_not_ the same as 91!).  MONTH must be an
 integer in the range 1 to 12; DAY must be in the range 1 to 31.  If the
 specified month has fewer than 31 days and DAY is too large, the
 equivalent day in the following month will be used.
 
    The ‘date(MONTH, DAY)’ function builds a pure date form using the
 current year, as determined by the real-time clock.
 
    The ‘date(YEAR, MONTH, DAY, HMS)’ function builds a date/time form
 using an HMS form.
 
    The ‘date(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND)’ function builds a
 date/time form.  HOUR should be an integer in the range 0 to 23; MINUTE
 should be an integer in the range 0 to 59; SECOND should be any real
 number in the range ‘[0 .. 60)’.  The last two arguments default to zero
 if omitted.
 
    The ‘t J’ (‘calc-julian’) [‘julian’] command converts a date form
 into a Julian day count, which is the number of days since noon (GMT) on
 Jan 1, 4713 BC.  A pure date is converted to an integer Julian count
 representing noon of that day.  A date/time form is converted to an
 exact floating-point Julian count, adjusted to interpret the date form
 in the current time zone but the Julian day count in Greenwich Mean
 Time.  A numeric prefix argument allows you to specify the time zone;
 SeeTime Zones.  Use a prefix of zero to suppress the time zone
 adjustment.  Note that pure date forms are never time-zone adjusted.
 
    This command can also do the opposite conversion, from a Julian day
 count (either an integer day, or a floating-point day and time in the
 GMT zone), into a pure date form or a date/time form in the current or
 specified time zone.
 
    The ‘t U’ (‘calc-unix-time’) [‘unixtime’] command converts a date
 form into a Unix time value, which is the number of seconds since
 midnight on Jan 1, 1970, or vice-versa.  The numeric result will be an
 integer if the current precision is 12 or less; for higher precision,
 the result may be a float with (PRECISION−12) digits after the decimal.
 Just as for ‘t J’, the numeric time is interpreted in the GMT time zone
 and the date form is interpreted in the current or specified zone.  Some
 systems use Unix-like numbering but with the local time zone; give a
 prefix of zero to suppress the adjustment if so.
 
    The ‘t C’ (‘calc-convert-time-zones’) [‘tzconv’] command converts a
 date form from one time zone to another.  You are prompted for each time
 zone name in turn; you can answer with any suitable Calc time zone
 expression (SeeTime Zones).  If you answer either prompt with a
 blank line, the local time zone is used for that prompt.  You can also
 answer the first prompt with ‘$’ to take the two time zone names from
 the stack (and the date to be converted from the third stack level).