ô > 6502.ProgTips.DofWeek 0ô Calculate day of week for 8-bit year range 7ô Works for any date from 1900-01-01 to 2155-12-31. (: 2 Þ mc% 59 < ã P=0 ¸ 1 FP%=mc%:O%=P% P[OPT P*2+4 Z\ On entry A=day, 1..31 d\ X=month, 1..12 n#\ Y=year-1900, 0..255 xB\ On exit A=day of week 0..6 for Sun..Sat, Carry will be Set ‚?\ Needs incrementing with ADC #0 after calling to Œ*\ become standard 1..7 range –P\ Size 56 bytes + 1 byte workspace (50 bytes if year 1900 test removed)  \ ª.DayOfWeek ´RCPX #3:BCS dow_march :\ Year starts in March to bypass leap year problem ¾FCPY #0:BNE dow_1901:LDY #6 :\ Include this line to adjust for 1900 È .dow_1901 Ò?DEY :\ If Jan or Feb, decrement year Ü.dow_march æ=‚ #&7F :\ Invert A so carry works right ðACPY #2100-1900 :\ Carry will be 1 if 22nd century ú4ADC dow_months-1,X :\ A=day+month_offset STA dow_tmp HTYA:JSR dow_mod7 :\ Get the year MOD 7 to prevent overflow QSBC dow_tmp:STA dow_tmp :\ A=day+month_offset+year using SEC from dow_mod7 "4TYA:LSR A:LSR A :\ Get the year DIV 4 ,WCLC:ADC dow_tmp :\ A=day+month_offset+year+year/4, fall through to MOD 7 6 .dow_mod7 @BADC #7:BCC dow_mod7 :\ Reduce A to A MOD 7, returns SEC J\\ADC #0 :\ Include to return 1-7, also swaps CC so JSR dow_mod7 works TRTS ^.dow_months h1EQUB 1:EQUB 5:EQUB 6:EQUB 3 :\ Month offsets rEQUB 1:EQUB 5:EQUB 3:EQUB 0 |EQUB 4:EQUB 2:EQUB 6:EQUB 4 † .dow_tmp 0EQUB 0 :\ Temporary storage š\ ¤]í ®1ݤday(A%):=Á"SunMonTueWedThuFriSat",A%*3-2,3) ¸ã X%=1 ¸ 12 Âã A%=1 ¸ 31 Ì?ñ A%;"/";X%;"/";1900+Y%;" - ";¤day(1+((º DayOfWeek) € 255)) Ö.ç A%=30:ç X%=4 „ X%=6 „ X%=9 „ X%=11:A%=32 à7ç A%=28:ç X%=2:ç (Y% ƒ 4) „ ((Y%+1900) ƒ 400):A%=32 êç A%=29:ç X%=2:A%=32 ôí þí ÿ