.; .; Title: TIMCHANGE.CMD .; Author: T. R. Wyant (DuPont) .; Date: 12-Sep-1985 .; Modified: .; Remarks: .; This command file is used to change a system to/from .; Daylight Savings time. The algorithm is as follows: .; .; Determine when the next time change is. .; Resubmit self as batch job, to run next time change. .; IF today is time change day THEN .; Change the time in the appropriate direction .; Reschedule tasks in the clock queue .; ENDIF .; .; The subroutines used to do date/time manipulation may .; be of interest in their own right. .; .ENABLE SUBSTITUTION ;+ ; '' ; .SETS S$DCL "DCL " ! Explicitly pass DCL commands to DCL. .SETS S$MCR "MCR " ! Explicitly pass MCR commands to MCR. .IF = "DCL" .SETS S$DCL "" ! DCL cmds implicit. .IF = "MCR" .SETS S$MCR "" ! MCR cmds implicit. .TESTDEVICE TI: ! Find out where we are running. .PARSE "," S$TI S$JUNK ! Save our TI: unit. no. .SETS S$JUNK S$TI[1:2] ! Get the driver name. .SETT L$CAN ! Assume OK to cancel. .IF S$JUNK = "VT" .SETF L$CAN ! If a VT, not OK. .SETS S$SVP1 P1 ! Save P1. .SETS S$OUIC ! Save UIC. .SETF L$SCH ! Not a schedule-only. .SETT L$TST ! A test. .PARSE S$SVP1 "/" S$DATE S$SVP1 ! Strip off the date. .IF S$DATE <> "" .GOTO P1LPE ! If a date given, process. .SETS S$DATE ! Use the real date. .SETF L$TST ! Not a test. .GOTO P1LPE ! Enter parser loop at bottom. .P1LP: .PARSE S$SVP1 "/" S$SW S$SVP1 ! Pick off the next switch. .IF S$SW = "" .GOTO P1LPE ! If null, ignore. .TEST S$SW ! Check it out. .IFF .GOTO P1LPE ! If not proper format, ignore. .IF > 4 .GOTO P1LPE ! If too long, ignore. .IFNDF L$'S$SW' .GOTO P1LPE ! If no such switch, ignore. .SETT L$'S$SW' ! Set the switch. .P1LPE: .IF S$SVP1 <> "" .GOTO P1LP ! If not done, loop again. .GOSUB CNVDAT 'S$DATE' .GOSUB JULDAT '' .PARSE "/" S$JD S$YR ! Separate the JD and year. .SETN D$CUJD 'S$JD'. ! Save the current Julian date. .SETN D$CUYR 'S$YR'. ! Save the current Julian date. .SETN D$TMYR D$CUYR ! Assume next run is this year. .SETS S$TMMD "3/31" ! Find the next Sunday .GOSUB USUAL ! AFTER 3/31 .IF D$TMJD >= D$CUJD .GOTO SPRING ! If yet to come, fine. .SETS S$TMMD "10/24" ! Find next Sunday .GOSUB USUAL ! AFTER 10/24 .IF D$TMJD >= D$CUJD .GOTO FALL ! If yet to come, fine. .INC D$TMYR ! No time chg this year. .SETS S$TMMD "3/31" ! Find the next Sunday AFTER .GOSUB USUAL ! 3/31 of next year. .GOTO SPRING ! Set it up as spring change. .SPRING:.SETS S$DESC "Standard Time to Daylight Saving Time" .SETS S$INCR "+1." ! Spring forward. .IF D$TMJD <> D$CUJD .GOTO FOUNDS ! If not the day, sched. .SETS S$TMMD "10/24" ! Find next Sunday .GOSUB USUAL ! AFTER 10/24 .GOTO FOUND ! Go join common code. .FALL: .SETS S$DESC "Daylight Saving Time to Standard Time" .SETS S$INCR "-1." ! Fall back. .IF D$TMJD <> D$CUJD .GOTO FOUNDS ! If not the day, sched. .INC D$TMYR ! Schedule for next yr. .SETS S$TMMD "3/31" ! Find the next Sunday AFTER .GOSUB USUAL ! 3/31 of next year. .GOTO FOUND .USUAL: .GOSUB JULDAT 'S$TMMD'/'D$TMYR' .PARSE "/" S$JD S$YR ! Get the Julian day and year. .SETN D$TMJD 'S$JD'. ! Convert the Julian day to numb .SETN D$TMYR 'S$YR'. ! Convert the year to a number. .GOSUB WKDAY '' .PARSE "/" S$JD S$YR ! Secure the day number. .SETN D$INCR 7.-'S$JD'. .SETN D$TMJD D$TMJD+D$INCR ! Move forward to next Sunday. .RETURN ! Return to caller. .FOUNDS:.SETT L$SCH .FOUND: .GOSUB INCDAT 'S$TMMD'/'D$TMYR' 'D$INCR' .PARSE "/" S$SCHD S$JD S$YR ! Find the actual date. .TEST S$YR ! Keep only the last 2 .SETS S$YR S$YR[-1:] ! digits of the year. .SETN D$JUNK 'S$SCHD'.*3-2 ! Index into month table .SETS S$SCHD "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC" .SETS S$SCHD S$JD+"-"+S$SCHD[D$JUNK:D$JUNK+2]+"-"+S$YR .SETS S$TXT "Convert " .IFT L$SCH .SETS S$TXT "Schedule conversion of " .IFT L$TST .SETS S$TXT "Test conversion of " .IFT L$TST .IFT L$SCH .SETS S$TXT "Test scheduling conversion of " .; ; 'S$TXT''S$DESC' ;- .IFDISABLED MCR .SETF L$TST .IFT L$TST .DISABLE MCR .IFDISABLED MCR .GOTO SUBMIT .TESTFILE TIMCHANGE.BAT .IF = 1 .GOTO SUBMIT .OPEN TIMCHANGE.BAT .ENABLE DATA $JOB $@LB:TIMCHANGE $EOJ .DISABLE DATA .CLOSE .SUBMIT:.IFT L$CAN 'S$MCR'QUE SYSBAT:TIMCHANGE/DEL/NM 'S$MCR'SUB SYSBAT:/AF:2:00:'S$SCHD'/NOPRIN=TIMCHANGE.BAT .IFT L$SCH .EXIT 'S$MCR'PIP TIMCHANGE.LOG/PU & *.*;1/RE=TIMCHANGE.LOG .TESTDEVICE TI: .SETS S$JUNK [1:2] .SETT L$DO .IF S$JUNK <> "VT" .ASK L$DO Is this really what you want to do .IFF L$DO .EXIT .PARSE