[comp.sys.handhelds] _Short_ Program

caster@eecs.cs.pdx.edu (Brad J. Caster) (02/27/90)

Has everyone heard of Zeller's Congruence?  Assuming some of us haven't,
here it is:

     D is the day of the month.
     M is the month with March being 1 and January and February being
          months 11 and 12 of the previous year.
     C is the century.
     Y is the year.

     d is the day of the week with Sunday as 0 and Saturday as 6.


     d = ((26*M - 2)//10 + D + Y + Y//4 + C//4 - 2*C)


     (// is integer division with truncation)


     [Yes, the part above looks alot like what appeared in another 
      news group years ago.  I only have the information, now, not
      the poster's name.  If I did, I'd give him/her credit.  Maybe
      he/she doesn't read this group (I'm safe...).                ]



---Rest for HP-28S---

If the stack looks like this,: 3: mm
                               2: dd
                               1: ccyy

CAL will display the days of the week for the week of the date given.

[CAL]
________________________
<< CLLCD 100 / DUP IP
SWAP FP 100 * 4 ROLL
2 -
  IF DUP 0 <=
  THEN 12 + SWAP 1 -
SWAP
  END -> D C Y M
  << 26 M * 2 - 10 /
IP D + Y DUP 4 / IP
+ + C 2 * - C 4 / IP
+ 7 MOD "" SWAP NEG
D + DUP 6 +
    FOR I I
      IF DUP 0 <=
      THEN DROP
"   "
      ELSE ->STR
        IF DUP SIZE
1 ==
        THEN "  "
        ELSE " "
        END +
      END +
    NEXT
"SU MO TU WE TH FR SA"
1 DISP 2 DISP
  >>
>>
________________________

caster@eecs.cs.pdx.edu (Brad J. Caster) (02/27/90)

Oops!  I'll catch myself before anyone else gets a chance.
In the formula, add 'mod 7' (modulo 7):

>     d = ((26*M - 2)//10 + D + Y + Y//4 + C//4 - 2*C) mod 7

-----