Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 13
Working With 48-Bit Timestamps
Converting Between Julian Day Numbers and Gregorian
Dates
To convert a Julian day number into a Gregorian date, you supply the
INTERPRETJULIANDAYNO procedure with the Julian day number. The procedure
returns the Gregorian date in the parameters year, month, and day. The Julian day
number must be greater than or equal to 1,721,119, and no greater than 3,182,395,
which refers to December 31, year 4000 of the Gregorian calendar. The following
example returns the current Gregorian date:
JULIAN^TIMESTAMP := JULIANTIMESTAMP(CURRENT^GMT);
JULIAN^DAY^NUMBER := INTERPRETTIMESTAMP(JULIAN^TIMESTAMP,
DATE^AND^TIME);
CALL INTERPRETJULIANDAYNO(JULIAN^DAY^NUMBER,
YEAR,MONTH,DAY);
To convert a Gregorian date into a Julian day number, you supply the
COMPUTEJULIANDAYNO procedure with the Gregorian year, month, and day of the
month. The procedure returns the Julian day number. For example:
YEAR := 1952;
MONTH := 11;
DATE := 9;
JULIANDAYNO := COMPUTEJULIANDAYNO(YEAR,MONTH,DAY,ERROR^MASK);
IF ERROR^MASK <> 0 THEN CALL BAD^DATE;
The errormask parameter provides the result of validity checking of the Gregorian
date. Bit 0 (the most significant bit) of the errormask parameter is set to 1 if the year
is outside the range 1 through 4000; bit 1 is set to 1 if the month is outside the range
1 through 12; and bit 2 is set if the day of the month is outside the range 1 through 31
for a month that has 31 days or outside the range 1 through 30 for a month that has
30 days. For the month of February, bit 2 is set if the date is outside the range
1 through 28 if it is not a leap year, or 1 through 29 if it is a leap year.
Converting a Julian Day Number Into a Day of the Week
You can find out the day of the week of a specified Julian day number using the
DAYOFWEEK procedure. You need to supply the DAYOFWEEK procedure with the
Julian day number; the procedure returns the day of the week represented by an
integer value: 0 represents Sunday, 1 represents Monday, and so on. For example:
DAY := DAYOFWEEK(JULIAN^DAY^NUMBER);
Working With 48-Bit Timestamps
A 48-bit timestamp measures the time since the start of December 31, 1974. All dates
and times are in local civil time, and the unit of measurement is 0.01 second.
You can use a 48-bit timestamp when you are only concerned with LCT. Such a
timestamp should not be compared with other timestamps nor referred to from a