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