home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdate20.zip / daylight.cmd next >
OS/2 REXX Batch file  |  1995-06-12  |  1KB  |  32 lines

  1. /* Find Daylight Savings change dates */
  2.  
  3. dateFormat = '%A %B %d'
  4.  
  5. if RxFuncQuery('RxDate')
  6.     then call RxFuncAdd 'RxDate', 'RexxDate', 'RxDate'
  7.  
  8. parse arg Year 
  9.  
  10. if Year = '' then do
  11.     say 'Calculate the beginning and ending of Daylight Savings Time'
  12.     say 'in the United States'
  13.     say '  (First Sunday in April and last Sunday in October)'
  14.     say 'Usage: Daylight <year>'
  15.     return
  16. end
  17.  
  18. DaylightStart = rxDate(year'-4-1')  
  19. DayOfWeek =  rxDate(DaylightStart, '%w')
  20. if DayOfWeek > 0 /* If April 1st isn't a Sunday, jump ahead to the next one */
  21.     then DaylightStart = DaylightStart + (7 - DayOfWeek)
  22.  
  23. DaylightEnd = rxDate(year'-10-31') - rxDate(year'-10-31', '%w')
  24.  
  25. Today = rxDate()
  26.  
  27. say 'For the year' rxDate(DaylightStart, '%Y')
  28. say 'Daylight Savings starts on:' rxDate(DaylightStart, dateFormat) 
  29. say '                           ' DaylightStart - Today 'days from now'
  30. say '               and ends on:' rxDate(DaylightEnd, dateFormat)
  31. say '                           ' DaylightEnd - Today 'days from now'
  32.