The computer program documented here is the copyrighted property of David William Noon, published in 1995. This program may be distributed freely, provided that the copies distributed are not altered from the original and that no charge is levied beyond the price of the medium of distribution. The author does not relinquish the rights of this intellectual property.
Overview
Twice a year, every year, it becomes necessary to change the Time-Of-Day (or TOD) clock on every computer you own. This is a chore that the computer itself should be able to handle. Well, now it is able to handle it.
The switching to and from Daylight Saving Time can now be automated by means of a program that remains in the background using no CPU cycles except on those two occasions each year when the clocks need to be changed. Such a program is included in the archive with this document.
The Program
The program DYLTSWCH.EXE functions under OS/2 like a daemon does under Unix. It "sleeps" in the background, waking up only at selected times. When it does wake up it adjusts the machine's TOD clock and then goes back to sleep for another 6 months (or so).
Since I have included the source code in the archive you can see for yourself how this is achieved. The DELAY statement of PL/I is a thin wrapper over the DosSleep() API call.
Defining Your Time Zone to the Operating System
The program uses the TZ environment variable. This variable defines the time zone in which the computer resides; its value can be set by means of a SET command, preferably in your CONFIG.SYS file. This variable is one OS/2 has inherited from Unix and the default settings are for Bell Laboratories in New Jersey, where Unix was first developed. The following is the definition of the fields within the TZ variable.
Thus, the time zone variable is coded as:
SET TZ=SSS[+|-]nDDD[,sm,sw,sd,st,em,ew,ed,et,shift]
As you can see from the table, all the defaults apply to the Eastern Standard Time zone of the United States.
The only sub-parameters that might need further description are the 'sw' and 'ew' fields. These tell the system whether the starting/ending day for DST is specified as a day of the month or a day of the week within a given week of the month. If the value for 'sw' or 'ew' is zero then the corresponding 'sd' or 'ed' is a day of the month. If the value for 'sw' or 'ew' is positive then the corresponding 'sd' or 'ed' is a day of the week (0=Sunday, 1=Monday, . . .) and 'sw' or 'ew' defines which occurrence of that day of the week within the month (1=first, 2=second, 3=third, 4=fourth). If the value for 'sw' or 'ew' is negative then the corresponding 'sd' or 'ed' is a day of the week (as before) and the 'sw' or 'ew' defines which occurrence of that day of the week reversing from the end of the month (-1=last, -2=second last, -3=third last, -4=fourth last).
How to Start the Program
This program must be in the system at the very instant that switching to or from DST is to occur. It cannot know when it is started that the clock needed to be changed several hours or days ago. Thus, it is best that you start the program every time you boot your machine.
If you live outside the U.S. eastern time zone
, I suggest that you include in your CONFIG.SYS a SET statement that establishes your time zone. Since the SET statements in CONFIG.SYS have not been processed at the time the RUN= statements are processed, you will need to delay the starting of the program until after CONFIG.SYS has been fully processed. Hence, you should use the STARTUP.CMD file and place in it the line
DETACH x:\directory\DYLTSWCH.EXE
This will create a minimal-resource background process after the TZ variable has been set.
Alternatively, you can place the time zone parameters on the RUN= statement in your CONFIG.SYS, as follows:
Now you can be asleep at 2:00 AM and still have your computer's clock changed on time!
Switching To/From Daylight Saving Time
Copyright (C) 1995 David W. Noon
All rights reserved Page
VariableDescriptionDefault
SSSStandard time zone identifier. This must be 3 characters, must begin with a letter and can contain spaces.EST
nDifference, in hours, between the standard time zone and Coordinated Universal Time (CUT), formerly known as Greenwich Mean Time (GMT). A positive number denotes a time zone west of Greenwich and a negative number denotes a time zone east of Greenwich.+5
DDDDaylight Saving Time (DST) time zone identifier.
This must be 3 characters, must begin with a letter and can contain spaces.EDT
smStarting month (1 to 12) of DST.4
swStarting week (-4 to +4) of DST.1
sdStarting day of DST.
1 to 31 if sw = 0
0 to 6 if sw
stStarting time (in seconds from midnight) of DST.3600
emEnding month (1 to 12) of DST.10
ewEnding week (-4 to +4)-1
edEnding day of DST.
1 to 31 if ew = 0
0 to 6 if ew
etEnding time (in seconds from midnight) of DST.7200