home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
dyltswch.lzh
/
DYLTSWCH.TXT
< prev
next >
Wrap
Text File
|
1995-04-06
|
8KB
|
129 lines
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!