Day of the week of Christmas and New Year: Difference between revisions
Content added Content deleted
Catskill549 (talk | contribs) (added AWK) |
(Added Algol W) |
||
Line 4: | Line 4: | ||
<br> |
<br> |
||
Determine programatically and show on this page on what weekday Christmas Day, 2021 and New Year's Day, 2022 will fall or did fall. |
Determine programatically and show on this page on what weekday Christmas Day, 2021 and New Year's Day, 2022 will fall or did fall. |
||
=={{header|ALGOL W}}== |
|||
Re-using code from the [[Day of the week]] task. |
|||
<lang algolw>begin % find the day of the week 25/12/2021 and 01/01/2022 fall on % |
|||
string(10) array dayName( 0 :: 6 ); |
|||
integer procedure Day_of_week ( integer value d, m, y ); |
|||
begin |
|||
integer j, k, mm, yy; |
|||
mm := m; |
|||
yy := y; |
|||
if mm <= 2 then begin |
|||
mm := mm + 12; |
|||
yy := yy - 1; |
|||
end if_m_le_2; |
|||
j := yy div 100; |
|||
k := yy rem 100; |
|||
(d + ( ( mm + 1 ) * 26 ) div 10 + k + k div 4 + j div 4 + 5 * j ) rem 7 |
|||
end Day_of_week; |
|||
dayName( 0 ) := "Saturday"; dayName( 1 ) := "Sunday"; dayName( 2 ) := "Monday"; |
|||
dayName( 3 ) := "Tuesday"; dayName( 4 ) := "Wednesday"; dayName( 5 ) := "Thursday"; |
|||
dayName( 6 ) := "Friday"; |
|||
write( "25th of December 2021 is a ", dayName( Day_of_week( 25, 12, 2021 ) ) ); |
|||
write( " 1st of January 2022 is a ", dayName( Day_of_week( 1, 1, 2022 ) ) ) |
|||
end.</lang> |
|||
{{out}} |
|||
<pre> |
|||
25th of December 2021 is a Saturday |
|||
1st of January 2022 is a Saturday |
|||
</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
Line 27: | Line 56: | ||
01 Jan 2022 is Saturday |
01 Jan 2022 is Saturday |
||
</pre> |
</pre> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2021-06-02}} |
{{works with|Factor|0.99 2021-06-02}} |