Switching To/From Daylight Saving Time Legalese The computer program docuemnted here is the copyrighted property of David William Noon, published 1995. The 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. Switching To/From Daylight Saving Time 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. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» ºVariable ³ Description ³ Default º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºSSS ³ Standard time zone identifier. This must ³ EST º º ³ be 3 characters, must begin with letter ³ º º ³ and can contain spaces ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºn ³ Difference, in hours, between the ³ +5 º º ³ standard time zone and Coordinated ³ º º ³ Universal Time (CUT), formerly know 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. ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºDDD ³ Daylight Saving Time (DST) time zone ³ EDT º º ³ identifier. This must be 3 characters, ³ º º ³ must begin with a letter and can contain ³ º º ³ spaces. ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºsm ³ Starting month (1 to 12) of DST. ³ 4 º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºsw ³ Starting week (-4 to +4) of DST. ³ 1 º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºsd ³ Starting day of DST ³ 0 º º ³ 1 to 31 if sw = 0 ³ º º ³ 0 to 6 if sw ª= 0 ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºst ³ Starting time (in seconds from midnight) ³ 3600 º º ³ of DST. ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºem ³ Ending month (1 to 12) of DST. ³ 10 º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºew ³ Ending week (-4 to +4) of DST. ³ -1 º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºed ³ Ending day of DST ³ 0 º º ³ 1 to 31 if sw = 0 ³ º º ³ 0 to 6 if sw ª= 0 ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºet ³ Ending time (in seconds from midnight) of ³ 7200 º º ³ DST. ³ º ºÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄĺ ºshift ³ Amount of time change (in seconds). ³ 3600 º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ 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 Switching To/From Daylight Saving Time 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' and 'ew' define 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: RUN=x:\directory\DYLTSWCH.EXE GMT0BST,4,1,0,3600,10,-1,0,7200,3600 [Note that the above example is for the British Isles and all other places in the Greenwich time zone.] What if it breaks? Any problems or suggestions can be reported to the author, David W. Noon, via either of two means: Compuserve 72172,431 (Internet: 72172.431@compuserve.com) FidoNet David Noon 1:109/347 Now you can be asleep at 2:00 AM and still have your computer's clock changed on time!