Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 10
Working With 64-Bit Julian Timestamps
!Compute time since last update:
TIME^SINCE^LAST^UPDATE := REMOTE^GMT - TIME^OF^LAST^UPDATE;
END;
Converting Between a Julian Timestamp and a Gregorian
Date and Time
To obtain a Gregorian date and the time of day from a Julian timestamp, you supply the
INTERPRETTIMESTAMP procedure with the Julian timestamp. The procedure returns
the Gregorian date and the time of day (in Greenwich mean time) in the
date-and-time parameter, as well as the Julian day number in the returned value.
The following statement shows an example:
INT DATE^AND^TIME[0:7];
FIXED JULIAN^TIMESTAMP;
INT(32) JULIAN^DAY^NUMBER;
.
.
JULIAN^TIMESTAMP := JULIANTIMESTAMP(CURRENT^GMT);
JULIAN^DAY^NUMBER := INTERPRETTIMESTAMP(JULIAN^TIMESTAMP,
DATE^N^TIME);
The eight-word date-and-time parameter contains the information shown below.
Values in parentheses indicate the range of valid values:
DATE^AND^TIME[0] !Gregorian year such as 1990 (1-4000)
DATE^AND^TIME[1] !Gregorian month (1-12)
DATE^AND^TIME[2] !Gregorian day of the month (1-31)
DATE^AND^TIME[3] !Hour of the day (0-23)
DATE^AND^TIME[4] !Minute of the hour (0-59)
DATE^AND^TIME[5] !Second of the minute (0-59)
DATE^AND^TIME[6] !Millisecond of the second (0-999)
DATE^AND^TIME[7] !Microsecond of the millisecond (0-999)
To obtain a Julian timestamp from a Gregorian date and the time of day, you supply the
COMPUTETIMESTAMP procedure with the eight-word Gregorian date and time of day
in the date-n-time parameter. The following example converts the date April 11,
1990, at 1:43 p.m. into a 64-bit Julian timestamp:
DATE^AND^TIME[0] := 1990; !year
DATE^AND^TIME[1] := 4; !month
DATE^AND^TIME[2] := 11; !day
DATE^AND^TIME[3] := 13; !hour
DATE^AND^TIME[4] := 43; !minute
DATE^AND^TIME[5] := 0; !second
DATE^AND^TIME[6] := 0; !millisecond
DATE^AND^TIME[7] := 0; !microsecond
JULIAN^TIMESTAMP := COMPUTETIMESTAMP(DATE^N^TIME,
ERROR^MASK);
IF ERROR^MASK <> 0 THEN CALL INVALID^DATE;
The above example uses the errormask parameter to check the validity of the input.
If any part of the Gregorian date or time is outside the valid range, then the
corresponding bit is set in the errormask parameter. For example, if the year is