Guardian Programmer's Guide

Table Of Contents
Managing Time
Guardian Programmer’s Guide 421922-014
18 - 32
Interacting With the DST Transition Table
Note the following rules when adding entries to the DST table:
#include <zsysc>
#include <cextdecs(COMPUTETIMESTAMP,DST_TRANSITION_ADD_)>
zsys_ddl_dst_entry_def DSTEntry;
short error, dateAndTime[8], errorMask;
long long timeStampLow, timeStampHigh;
/* First DST period; April 14, 1991 through October 20, 1991,
Offset = 1 hour */
dateAndTime[0] = 1991; /* year */
dateAndTime[1] = 4; /* month */
dateAndTime[2] = 14; /* day */
dateAndTime[3] = 2; /* hour */
dateAndTime[4] = 0; /* minute */
dateAndTime[5] = 0; /* second */
dateAndTime[6] = 0; /* millisecond */
dateAndTime[7] = 0; /* microsecond */
timeStampLow = COMPUTETIMESTAMP(dateAndTime, &errorMask);
if (errorMask != 0) errorExit();
dateAndTime[0] = 1991; /* year */
dateAndTime[1] = 10; /* month */
dateAndTime[2] = 20; /* day */
dateAndTime[3] = 2; /* hour */
dateAndTime[4] = 0; /* minute */
dateAndTime[5] = 0; /* second */
dateAndTime[6] = 0; /* millisecond */
dateAndTime[7] = 0; /* microsecond */
timeStampHigh = COMPUTETIMESTAMP(dateAndTime, &errorMask);
if (errorMask != 0) errorExit();
DSTEntry.z_lowgmt = timeStampLow;
DSTEntry.z_highgmt = timeStampHigh;
DSTEntry.z_offset = 3600; /* seconds in 1 hour */
DSTEntry.z_version = DST_VERSION_SEP1997;
error = DST_TRANSITION_ADD_(&DSTEntry);
1. The z_lowgmt and z_highgmt fields must have values between 1/1/1 and
12/31/10000.
2. There must be no existing entry in the DST table for which both of the following
are true:
The entry has a nonzero offset
The entry overlaps the time period bounded by z_lowgmt and z_highgmt
fields.
3. The DST table stores entries with nonzero offset. The entries with zero offset are
deduced from the gaps in the table. Hence, if z_offset is zero and rules (1) and
(2) are satisfied, the operation does not affect the contents of the table. This
means that only entries with nonzero offset need to be added to the table.