home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / dst.zip / DST.CMD next >
OS/2 REXX Batch file  |  1996-10-04  |  3KB  |  61 lines

  1. /* George W. Barrowcliff       73324,2541                                *
  2. *  9/29/96  Version 1.0                                                  *
  3. *  This program resets the system clock at 2AM on October 27th, 1996     *
  4. *  It also writes a line in the IPL.LOG located in the C:\MISC directory *
  5. *     Daylight Savings Time Starts at 2AM on the First Sunday in April   *
  6. *                          and ends at 2AM on the last Sunday in October *
  7. *  It is left to the interested student to rework this program for       *
  8. *  The first Sunday in April, 1997 (Day 96), or to be year independant   */
  9.  
  10. /*  A companion program called DSTADD.CMD will add the program to the    *
  11. *   Startup Folder, so it will always load when the system is booted     */
  12.  
  13. debug=0
  14. IPLLog='C:\misc\ipl.log'
  15. Marker='DST-Fall'||Right(Date('N'),4)    /* DST-Fall1996 */
  16. Call RxFuncAdd 'RexxLibRegister','SysSleep','RexxLibRegister'  /* Will be needing this later */
  17. MinsDay=60*24
  18. SecsDay=MinsDay*60                 /* Seconds in a day for sleeping  */
  19. SecsHour=60*60                     /* Seconds in an Hour  */
  20. DSTday=301                         /* 10/27/96  Fall Back */
  21. Do Debug
  22.   DSTDay=Date('D') + 1             /*   Make it tomorrow for testing  */
  23. end /* do */
  24.                                    /*  If not already done .....  else quit   */
  25. Do while lines(IPLLog) > 0
  26.    If Left(linein(IPLLog),Length(Marker))=Marker then  Exit /*  Already been set this year  */
  27. end /* do */
  28. rc=Lineout(IPLLog)                 /*  Close log file  */
  29.  
  30. MinToMid=MinsDay - time("M")       /*  Minutes until tomorrow  */
  31. DaysThisYear=Date("D") +1          /*  at midnight it will be tomorrow   */
  32. do debug
  33.  trace r
  34.  rc=Time('N')  /* What time is it Now?  */
  35. end /* do */
  36. WaitTime= (DSTday-DaysThisYear)*1440 + MinToMid  + 120   /* Reset at 2AM  */
  37. DaysWaiting=WaitTime % MinsDay
  38. HoursToWait=(WaitTime // MinsDay) % 60
  39. MinsToWait=(WaitTime // MinsDay) // 60
  40. If DaysWaiting<0 | HoursToWait<0 | MinsToWait<0 then  Exit   /* Time already gone by  */
  41.   /*  Now the Waiting Starts  */   /* First wait out this hour           */
  42. Call SysSleep(MinsToWait*60)       /*  Must have an Int for an argument  */
  43. Call SysSleep(HoursToWait*SecsHour) /* Wait now until 2 AM tomorrow       */
  44.  
  45. Do DaysWaiting                     /*  Wait out the days until X time    */
  46.    Call SysSleep(SecsDay)          /* Those also serve that sit and wait */
  47. end /* do */
  48. Do Debug
  49.    Say Time('N')
  50. end /* do */
  51. /*  Should be 2:00 AM, Sunday Morning, October 27.  Time to Fall Back an hour  */
  52. Now=Time("M")-60                   /* Current time less an hour          */
  53. Now=Now%60||':'||Now//60
  54. /*     Issue the Command line text to reset the time.  */
  55. 'Time' Now
  56. /*  Time Reset, now keep it from happening again this year */
  57. Marker=Marker Time('N') Date('W') Date('N')   /* DST-Fall1996 02:01:41 Sunday 27 October 1996  */
  58. rc=Lineout(IPLLog,Marker)
  59. rc=Lineout(IPLLog)
  60. return
  61.