Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 8
Working With 64-Bit Julian Timestamps
TYPE := SINCE^COLD^LOAD;
TIME1 := JULIANTIMESTAMP(TYPE);
.
.
TYPE := SINCE^COLD^LOAD;
TIME2 := JULIANTIMESTAMP(TYPE);
INTERVAL := TIME2 - TIME1;
Obtaining a Julian Timestamp: Remote Node
If you are dealing with timestamps on a remote node, then the relevant Julian
timestamp is the one that is generated on that node. This is because system time on
the remote node may be different from system time on the local node; the operating
system makes no attempt to synchronize clocks between nodes.
If, for example, you want to know how much time has passed since a specific file on a
remote node was last updated, you would find out using the last update timestamp on
the file and the current timestamp from the remote node.
When establishing the current time on a remote node, you should attempt to
compensate for the time it takes to send the message containing the timestamp to the
local node. You find this out using the following sequence:
1. Call the JULIANTIMESTAMP procedure for the local node to return the number of
microseconds since cold load.
2. Call the JULIANTIMESTAMP procedure for the remote node.
3. Call the JULIANTIMESTAMP procedure for the local node to return the number of
microseconds since cold load.
4. Compute the difference between the timestamps returned in Steps 1 and 3. This is
the time taken to send a message from the local node to the remote node and then
to send a message back to the local node from the remote node.
5. Divide the time delay indicated in Step 4 by 2 to get the time to send a message in
one direction.
6. Add the delay indicated in Step 5 to the remote timestamp returned in Step 2. The
result is a current timestamp for the remote node.
The following example calculates the time since the last update of a file named DFILE
on a remote node named \SYS2.
LITERAL GET^TIME^OF^LAST^UPDATE = 144,
CURRENT^GMT = 0,
SINCE^COLD^LOAD = 3;
INT .RESULT[0:3],
Note. The above algorithm yields an approximate result. The error in the result can be as
large as the value computed in Step 5.