home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / rexx / 653 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.lang.rexx
  2. Path: sparky!uunet!psinntp!commpost!opus!fia!camelot!jogulin
  3. From: jogulin@camelot.fia.dmg.ml.com (Joseph Ogulin)
  4. Subject: Re:      Re: Determining weekday given a date
  5. Message-ID: <1992Jul23.131630.4430@fia.dmg.ml.com>
  6. Sender: jogulin@camelot (Joseph Ogulin)
  7. Nntp-Posting-Host: camelot
  8. Organization: The Rift from Here to There
  9. References:  <m0mA8o4-0000cyC@juts.ccc.amdahl.com>
  10. Date: Thu, 23 Jul 1992 13:16:30 GMT
  11. Lines: 39
  12.  
  13. In article <m0mA8o4-0000cyC@juts.ccc.amdahl.com>,         chip.davis@AMAIL.AMDAHL.COM writes:
  14. |> The following exec will probably do what you want, and is considerably
  15. |> shorter than the universal CA/ACM routine posted.
  16. |> -Chip-
  17. |> 
  18. |> ------------------Top of Exec-------------------------
  19. |> /* Return the weekday name for an arbitrary date in this century */
  20. |>   wk = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'
  21. |>   Parse Var wk wkday.0 wkday.1 wkday.2 wkday.3 wkday.4 wkday.5 wkday.6 .
  22. |>   Parse Value 31 30 30 30 30 With m. m.4 m.6 m.9 m.11 .
  23. |>   Parse Arg mm . '/' dd . '/' yy .
  24. |>   yr = yy + (yy = 0) * 100
  25. |>   m.2 = (yr // 4 = 0) + 28
  26.      ^^^^^^^^^^^^^^^^^^^^^^^^
  27. |>   d0 = ((yr - 1) % 4 + yr) // 7
  28. |>   d = 0
  29. |>   Do i = 1 To mm - 1
  30. |>     d = d + m.i
  31. |>   End i
  32. |>   d = (d + dd + d0) // 7
  33. |>   Return wkday.d
  34. |> -----------------------End of Exec---------------------
  35.  
  36. By your method, 1900 would have been a leap year and it is not.  To correctly
  37. define a leap year, you would have to do this:
  38.  
  39. m.2 = (((yr // 4 = 0) & (yr // 100 ^= 0)) | (yr // 400 = 0)) + 28
  40.  
  41. The year has to be divisible by 4 and not by 100 or divisible by 400.
  42.  
  43. -- 
  44. ==> "You never f**king know the answer when it's important." --The Doctor <==
  45. Joe Ogulin
  46.  
  47. jogulin@camelot.fia.dmg.ml.com        joe@monroe.pilot.dmg.ml.com
  48. jogulin@apollo.stevens-tech.edu        gcs_jogulin@stevens.bitnet
  49.  
  50. Disclaimer:  The above article is solely my opinion and does not necessar-
  51. ily reflect that of my employer.  The content is my responsibility alone.
  52.