Anonymous user
Day of the week: Difference between revisions
→{{header|Forth}}
Line 583:
=={{header|Forth}}==
Forth has only TIME&DATE, which does not give day of week. Many public Forth Julian date calculators had year-2100 problems, but this algorithm works well.
<lang forth>
\ Zeller's Congruence
: weekday
over 3 < if 1- swap 12 + swap then
swap dup
( in zeller 0=sat, so -2 to 0= mon, then mod, then 1+ for 1=mon)
▲ 1+ 7 mod ;
: yuletide
." December 25 is Sunday in "
2122 2008 do
25 12 i weekday
loop cr ;
</lang>
<lang forth>
December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
ok
</lang>
▲cr yuletide
▲December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</lang>
To show year-2100 problems with SwiftForth's provided Modified Julian Day support:
|