Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 11
Working With 64-Bit Julian Timestamps
outside the range 1 through 4000, then bit 0 (the most significant bit) is set to 1; if the
month is specified outside the range 1 through 12, then bit 1 is set; and so on.
Converting a GMT Timestamp Into Local Time
To convert a Julian timestamp representing GMT into a Julian timestamp representing
local time, or to convert a local Julian timestamp into a GMT Julian timestamp, you can
use the CONVERTTIMESTAMP procedure. The local time used by this procedure can
be local standard time (no adjustment made for daylight saving time) or local civil time
(time adjusted for daylight saving time). Moreover, the CONVERTTIMESTAMP
procedure can work with local time on any network node.
The following example converts GMT into LCT for the local node:
LITERAL GMT^TO^LCT = 0,
GMT^TO^LST = 1,
LCT^TO^GMT = 2,
LST^TO^GMT = 3;
INT NODE^NUMBER,
NODE^NAME[0:3];
LOCAL^CIVIL^TIME := CONVERTTIMESTAMP(JULIAN^GMT^TIMESTAMP,
GMT^TO^LCT);
The next example converts the LCT on the network node named \SYS3 into GMT:
NODE^NAME ':=' "\SYS3 ";
CALL LOCATESYSTEM(NODE^NUMBER,NODE^NAME);
GREENWICH^MEAN^TIME := CONVERTTIMESTAMP(LOCAL^CIVIL^TIME,
LCT^TO^GMT,
NODE^NUMBER);
Converting Microseconds Into Days, Hours, Minutes,
Seconds, Milliseconds, and Microseconds
You can convert a time period into a number of days, hours, minutes, seconds,
milliseconds, and microseconds using the INTERPRETINTERVAL procedure. For
example, you can compute the difference between two Julian timestamps and then
convert the result into a more readable form as follows:
LITERAL SINCE^COLD^LOAD = 3;
INT(32) DAYS;
INT HOURS,
MINUTES,
SECONDS,
MILLISECS,
MICROSECS;
FIXED TIME1,
TIME2,
INTERVAL;
.
.