Day of the week: Difference between revisions
Content added Content deleted
(→{{header|Ada}}: All sundays between 1901 and 2399) |
(Forth, Zeller's Congruence) |
||
Line 135: | Line 135: | ||
2037 is the last year we can specify |
2037 is the last year we can specify |
||
</pre> |
</pre> |
||
=={{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. |
|||
\ Zeller's Congruence |
|||
: zeller ( m -- days since March 1 ) |
|||
9 + 12 mod 1- 26 10 */ 3 + ; |
|||
: weekday ( d m y -- 0..6 ) \ Monday..Sunday |
|||
over 3 < if 1- then |
|||
dup >r |
|||
r@ 4 / + |
|||
r@ 100 / - |
|||
r> 400 / + |
|||
swap zeller + + |
|||
1+ 7 mod ; |
|||
: yuletide |
|||
." December 25 is Sunday in " |
|||
2122 2008 do |
|||
25 12 i weekday |
|||
6 = if i . then |
|||
loop cr ; |
|||
=={{header|Java}}== |
=={{header|Java}}== |