From lennartb@lne.kth.se Fri Aug 17 18:11:23 1990 From: lennartb@lne.kth.se (Lennart Boerjeson @ KTH/LNE, The Royal Inst. of Tech.) Newsgroups: comp.sys.handhelds Subject: Daylight Saving Time program Date: 16 Aug 90 21:39:10 GMT Reply-To: lennartb@lne.kth.se (Lennart Boerjeson @ KTH/LNE, The Royal Inst. of Tech.) Organization: KTH School of E.E. The following is a program which automatically, twice a year, switchs your clock between daylight saving time and standard time. It is designed to be used together with Eric Postpischil's timekeeping routines, install this directory as a subdirectory in the directory where Eric's routines are. It should also work without Eric's routines. The time changes on the last Sunday of March and September, if this isn't right for you, modify routine \->DSTDAY. Some of the routines have borrowed ideas from Eric's routines. Give credit where credit is due... (Some may ask "Why have an alarm that'll only execute twice a year?" Well... maybe I'm a little bit lazy... I have had such a program in my HP-41 for years, and I have NEVER been late on those frosty mornings in spring, the day after DST starts...) !++ ! Lennart Boerjeson, System Manager ! School of Electrical Engineering ! Royal Institute of Technology ! S-100 44 Stockholm, Sweden ! tel: int+46-8-7907814 ! Internet: lennartb@lne.kth.se !-- @ DST Daylight Saving Time program - 'DST' BYTES -> #118Ch 1096.5 %%HP: T(3)A(R)F(,); DIR STOAL @ Store Alarm. Previous copies of same alarm are deleted. @ alarm -> \<< \-> AL \<< RCLF -55 SF IFERR 1 \-> I \<< WHILE I RCLALARM IF AL SAME THEN I DELALARM 1 ELSE 'I' INCR END REPEAT END \>> THEN END STOF AL STOALARM DROP \>> \>> DSTDO @ Advance or delay clock, reschedule DST. @ -> \<< PATH SWAP HOME IF 'JOB' VTYPE 0 < THEN 29491200 * CLKADJ ELSE 'JOB' RCL 1 OVER SIZE 1 - SUB EVAL '1_h' \->UNIT ADJT END EVAL DSTSCHD \>> MKAL @ Make DST alarm. @ -> alarm \<< DATE \->DST IF MM 3 SAME THEN 2 1 ELSE 3 -1 END "\<< IFERR DELALARM PATH " SWAP + " 'DSTJOB' RCL EVAL EVAL THEN ERRM END OFF \>>" + OBJ\-> 0 4 \->LIST \>> MM @ Get month from date. @ date -> date mm \<< DUP IF -42 FS? THEN FP 100 * END IP \>> DSTSCHD @ Schedule DST alarm and create DSTJOB path in HOME. @ -> \<< PATH HOME IF 'DSTJOB' VTYPE 0 < THEN DUP 'DSTDO' + 'DSTJOB' STO END EVAL MKAL STOAL \>> \->DST @ Compute next DST day. @ date -> newdate \<< DUP \->DSTDAY IF DUP2 DDAYS 0 MAX NOT THEN ADDMONTH \->DSTDAY END SWAP DROP \>> ?DSTDAY @ Is this date a Sunday? @ date -> date flag \<< DUP 0 TSTR 1 3 SUB "SUN" SAME \>> ADDMONTH @ Add one month to date. @ date -> newdate \<< \->D1 31 DATE+ \->D1 \>> \->D1 @ Reset date to day 1 of same month. @ date -> newdate \<< IF -42 FS? THEN FP 1 + ELSE DUP IP SWAP 100 * FP 1 + 100 / + END \>> ?DSTMONTH @ Is this date in March or September? @ date -> date flag \<< MM DUP 3 SAME SWAP 9 SAME OR \>> \->DSTDAY @ Compute next DST day. If starting month is DSTmonth, return @ same month (\->DST checks this case). @ date -> newdate \<< WHILE ?DSTMONTH NOT REPEAT ADDMONTH END ADDMONTH DO -1 DATE+ UNTIL ?DSTDAY END \>> CST { } @ Empty CST menu. END !++ ! Lennart Boerjeson, System Manager ! School of Electrical Engineering ! Royal Institute of Technology ! S-100 44 Stockholm, Sweden ! tel: int+46-8-7907814 ! Internet: lennartb@lne.kth.se !--