Day of the week: Difference between revisions

no edit summary
No edit summary
Line 2,335:
<pre>
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</pre>
 
=={{header|XPL0}}==
The original routine in the library only worked correctly between the years
1980 and 2099. It was upgraded with this new routine that handles all dates in
the Gregorian calendar, from 1583 onward. It's based on Zeller's Congruence.
 
<lang XPL0>include c:\cxpl\codes; \intrinsic 'code' declarations
 
proc WeekDay(Year, Month, Day); \Return day of week (0=Sat 1=Sun..6=Fri)
int Year, Month, Day;
[if Month<=2 then [Month:= Month+12; Year:= Year-1];
return rem((Day + (Month+1)*26/10 + Year + Year/4 + Year/100*6 + Year/400) / 7);
]; \WeekDay
 
 
int Year;
[for Year:= 2008 to 2121 do
if WeekDay(Year, 12, 25) = 1 then \25th of December is a Sunday
[IntOut(0, Year); CrLf(0)];
]</lang>
 
Output:
<pre>
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</pre>
 
772

edits