Day of the week of Christmas and New Year: Difference between revisions

From Rosetta Code
Content added Content deleted
(J)
m (syntax highlighting fixup automation)
Line 8: Line 8:
{{trans|Python}}
{{trans|Python}}


<lang 11l>V weekDays = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]
<syntaxhighlight lang="11l">V weekDays = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]
V thisXMas = Time(2021, 12, 25)
V thisXMas = Time(2021, 12, 25)
V thisXMasDay = Int(thisXMas.strftime(‘%w’))
V thisXMasDay = Int(thisXMas.strftime(‘%w’))
Line 17: Line 17:
V nextNewYearDay = Int(nextNewYear.strftime(‘%w’))
V nextNewYearDay = Int(nextNewYear.strftime(‘%w’))
V nextNewYearDayAsString = weekDays[nextNewYearDay]
V nextNewYearDayAsString = weekDays[nextNewYearDay]
print(‘Next new year is on a ’nextNewYearDayAsString)</lang>
print(‘Next new year is on a ’nextNewYearDayAsString)</syntaxhighlight>


{{out}}
{{out}}
Line 26: Line 26:


=={{header|Ada}}==
=={{header|Ada}}==
<lang Ada>with Ada.Text_Io;
<syntaxhighlight lang="ada">with Ada.Text_Io;
with Ada.Calendar.Formatting;
with Ada.Calendar.Formatting;


Line 50: Line 50:
Info (Christmas_Day);
Info (Christmas_Day);
Info (New_Years_Day);
Info (New_Years_Day);
end Weekdays;</lang>
end Weekdays;</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 59: Line 59:
=={{header|ALGOL W}}==
=={{header|ALGOL W}}==
Re-using code from the [[Day of the week]] task.
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 %
<syntaxhighlight lang="algolw">begin % find the day of the week 25/12/2021 and 01/01/2022 fall on %
string(10) array dayName( 0 :: 6 );
string(10) array dayName( 0 :: 6 );
integer procedure Day_of_week ( integer value d, m, y );
integer procedure Day_of_week ( integer value d, m, y );
Line 79: Line 79:
write( "25th of December 2021 is a ", dayName( Day_of_week( 25, 12, 2021 ) ) );
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 ) ) )
write( " 1st of January 2022 is a ", dayName( Day_of_week( 1, 1, 2022 ) ) )
end.</lang>
end.</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 87: Line 87:


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>FormatTime, xmas , 20211225, dddd
<syntaxhighlight lang="autohotkey">FormatTime, xmas , 20211225, dddd
FormatTime, newYear , 20220101, dddd
FormatTime, newYear , 20220101, dddd
MsgBox % result := "Christmas Day, 2021 : " xmas "`nNew Year's Day, 2022 : " newYear</lang>
MsgBox % result := "Christmas Day, 2021 : " xmas "`nNew Year's Day, 2022 : " newYear</syntaxhighlight>
{{out}}
{{out}}
<pre>Christmas Day, 2021 : Saturday
<pre>Christmas Day, 2021 : Saturday
Line 95: Line 95:


=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f WHAT_WEEKDAYS_WILL_CHRISTMAS_AND_NEW_YEAR.AWK
# syntax: GAWK -f WHAT_WEEKDAYS_WILL_CHRISTMAS_AND_NEW_YEAR.AWK
BEGIN {
BEGIN {
Line 107: Line 107:
exit(0)
exit(0)
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 118: Line 118:


=={{header|BASIC}}==
=={{header|BASIC}}==
<lang gwbasic>10 DEFINT A-Z
<syntaxhighlight lang="gwbasic">10 DEFINT A-Z
20 DIM D$(6)
20 DIM D$(6)
30 FOR I=0 TO 6: READ D$(I): NEXT
30 FOR I=0 TO 6: READ D$(I): NEXT
Line 132: Line 132:
130 DATA Saturday,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday
130 DATA Saturday,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday
140 DATA 2021,12,25
140 DATA 2021,12,25
150 DATA 2022,1,1</lang>
150 DATA 2022,1,1</syntaxhighlight>
{{out}}
{{out}}
<pre>12/25/2021 is a Saturday
<pre>12/25/2021 is a Saturday
Line 138: Line 138:


=={{header|BCPL}}==
=={{header|BCPL}}==
<lang bcpl>get "libhdr"
<syntaxhighlight lang="bcpl">get "libhdr"


let dayofweek(y,m,d) = valof
let dayofweek(y,m,d) = valof
Line 166: Line 166:
$( show(2021,12,25)
$( show(2021,12,25)
show(2022,1,1)
show(2022,1,1)
$)</lang>
$)</syntaxhighlight>
{{out}}
{{out}}
<pre>12/25/2021 is a Saturday
<pre>12/25/2021 is a Saturday
Line 172: Line 172:


=={{header|C}}==
=={{header|C}}==
<lang c>#define _XOPEN_SOURCE
<syntaxhighlight lang="c">#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdio.h>
#include <time.h>
#include <time.h>
Line 186: Line 186:
}
}
return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>2021-12-25 is a Saturday
<pre>2021-12-25 is a Saturday
Line 192: Line 192:


=={{header|CLU}}==
=={{header|CLU}}==
<lang clu>day_of_week = proc (d: date) returns (string)
<syntaxhighlight lang="clu">day_of_week = proc (d: date) returns (string)
own days: array[string] := array[string]$
own days: array[string] := array[string]$
[0:"Saturday", "Sunday", "Monday", "Tuesday",
[0:"Saturday", "Sunday", "Monday", "Tuesday",
Line 218: Line 218:
stream$putl(po, date$unparse_date(d) || " is a " || day_of_week(d))
stream$putl(po, date$unparse_date(d) || " is a " || day_of_week(d))
end
end
end start_up</lang>
end start_up</syntaxhighlight>
{{out}}
{{out}}
<pre>25 December 2021 is a Saturday
<pre>25 December 2021 is a Saturday
Line 224: Line 224:


=={{header|COBOL}}==
=={{header|COBOL}}==
<lang cobol> IDENTIFICATION DIVISION.
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. XMASNY.
PROGRAM-ID. XMASNY.
Line 298: Line 298:
MULTIPLY 7 BY D7.
MULTIPLY 7 BY D7.
COMPUTE D = D - D7 + 1.
COMPUTE D = D - D7 + 1.
MOVE DAYS(D) TO DAY-NAME.</lang>
MOVE DAYS(D) TO DAY-NAME.</syntaxhighlight>
{{out}}
{{out}}
<pre>25/12/2021 is a Saturday
<pre>25/12/2021 is a Saturday
Line 304: Line 304:


=={{header|Cowgol}}==
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
<syntaxhighlight lang="cowgol">include "cowgol.coh";


record Date is
record Date is
Line 353: Line 353:
print_nl();
print_nl();
i := i + 1;
i := i + 1;
end loop;</lang>
end loop;</syntaxhighlight>
{{out}}
{{out}}
<pre>25/12/2021 is a Saturday
<pre>25/12/2021 is a Saturday
Line 359: Line 359:


=={{header|Draco}}==
=={{header|Draco}}==
<lang draco>type Date = struct {
<syntaxhighlight lang="draco">type Date = struct {
word year;
word year;
byte month, day
byte month, day
Line 398: Line 398:
writeln(" is a ", day_name(dates[i]))
writeln(" is a ", day_name(dates[i]))
od
od
corp</lang>
corp</syntaxhighlight>
{{out}}
{{out}}
<pre>12/25/2021 is a Saturday
<pre>12/25/2021 is a Saturday
Line 404: Line 404:


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
<lang fsharp>
<syntaxhighlight lang="fsharp">
// Show day of week for Christmas Day, 2021 and New Year's Day, 2022. Nigel Galloway: December 1st., 2021
// Show day of week for Christmas Day, 2021 and New Year's Day, 2022. Nigel Galloway: December 1st., 2021
printfn $"Christmas Day 2021 is a %s{string(System.DateTime(2021,12,25).DayOfWeek)}. New Years Day 2022 is a %s{string(System.DateTime(2022,1,1).DayOfWeek)}."
printfn $"Christmas Day 2021 is a %s{string(System.DateTime(2021,12,25).DayOfWeek)}. New Years Day 2022 is a %s{string(System.DateTime(2022,1,1).DayOfWeek)}."
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 415: Line 415:
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: calendar calendar.english calendar.holidays.us formatting
<syntaxhighlight lang="factor">USING: calendar calendar.english calendar.holidays.us formatting
kernel sequences ;
kernel sequences ;


Line 427: Line 427:
: .holidays ( seq -- ) [ dup holidays msg printf ] each ;
: .holidays ( seq -- ) [ dup holidays msg printf ] each ;


{ 1578 1590 1642 1957 2020 2021 2022 2242 2245 2393 } .holidays</lang>
{ 1578 1590 1642 1957 2020 2021 2022 2242 2245 2393 } .holidays</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 443: Line 443:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>#include "vbcompat.bi" 'contains functions for dealing with dates and times
<syntaxhighlight lang="freebasic">#include "vbcompat.bi" 'contains functions for dealing with dates and times
#include "string.bi" 'contains functions for formatting text strings
#include "string.bi" 'contains functions for formatting text strings


Line 450: Line 450:


print "Christmas Day 2021 is on a "; format(christmas,"dddd")
print "Christmas Day 2021 is on a "; format(christmas,"dddd")
print "New Year's Day 2022 is on a "; format(newyears, "dddd")</lang>
print "New Year's Day 2022 is on a "; format(newyears, "dddd")</syntaxhighlight>
{{out}}<pre>
{{out}}<pre>
Christmas Day 2021 is on a Saturday
Christmas Day 2021 is on a Saturday
Line 457: Line 457:


=={{header|J}}==
=={{header|J}}==
<lang J> (weekday 2021 12 25){::;:'Sun Mon Tue Wed Thu Fri Sat'
<syntaxhighlight lang="j"> (weekday 2021 12 25){::;:'Sun Mon Tue Wed Thu Fri Sat'
Sat
Sat
(weekday 2022 01 01){::;:'Sun Mon Tue Wed Thu Fri Sat'
(weekday 2022 01 01){::;:'Sun Mon Tue Wed Thu Fri Sat'
Sat</lang>
Sat</syntaxhighlight>
=={{header|jq}}==
=={{header|jq}}==
{{works with|jq}}
{{works with|jq}}
Line 467: Line 467:
Years, output format, and output are exactly as for [[#Wren|Wren]].
Years, output format, and output are exactly as for [[#Wren|Wren]].


<lang jq>def weekdaynames:
<syntaxhighlight lang="jq">def weekdaynames:
["Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
["Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];


Line 475: Line 475:


1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393
1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393
| "In \(.), New year's day is on a \(weekday(.;1;1)), and Christmas day on \(weekday(.;12;25))."</lang>
| "In \(.), New year's day is on a \(weekday(.;1;1)), and Christmas day on \(weekday(.;12;25))."</syntaxhighlight>
{{out}}
{{out}}
As for [[#Wren]]
As for [[#Wren]]
Line 481: Line 481:
=={{header|Julia}}==
=={{header|Julia}}==
See also https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.format-Tuple{TimeType,%20AbstractString}
See also https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.format-Tuple{TimeType,%20AbstractString}
<lang julia>using Dates
<syntaxhighlight lang="julia">using Dates


for year in [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
for year in [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
Line 487: Line 487:
" and Christmas: ", Dates.format(DateTime(year, 12, 25), "E, U d, Y"))
" and Christmas: ", Dates.format(DateTime(year, 12, 25), "E, U d, Y"))
end
end
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Year 1578, New Years's Day: Sunday, January 1, 1578 and Christmas: Monday, December 25, 1578
Year 1578, New Years's Day: Sunday, January 1, 1578 and Christmas: Monday, December 25, 1578
Line 502: Line 502:


=={{header|ooRexx}}==
=={{header|ooRexx}}==
<lang oorexx>/* REXX */
<syntaxhighlight lang="oorexx">/* REXX */
Call wkd 2021,12,25
Call wkd 2021,12,25
Call wkd 2022,01,01
Call wkd 2022,01,01
Line 511: Line 511:
dt=.DateTime~new(y,m,d)
dt=.DateTime~new(y,m,d)
say d'.'m'.'y 'is a' wd[dt~weekday]
say d'.'m'.'y 'is a' wd[dt~weekday]
Return</lang>{{out}}
Return</syntaxhighlight>{{out}}
<pre>25.12.2021 is a Saturday
<pre>25.12.2021 is a Saturday
01.01.2022 is a Saturday<</pre>
01.01.2022 is a Saturday<</pre>


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>#!/usr/bin/perl
<syntaxhighlight lang="perl">#!/usr/bin/perl


use strict; # https://rosettacode.org/wiki/What_weekdays_will_Christmas_and_New_Year
use strict; # https://rosettacode.org/wiki/What_weekdays_will_Christmas_and_New_Year
Line 529: Line 529:
print "$_->[0] ", qw( Sunday Monday Tuesday Wednesday Thursday Fridat Saturday )
print "$_->[0] ", qw( Sunday Monday Tuesday Wednesday Thursday Fridat Saturday )
[(localtime timelocal(0, 0, 12, @{$_}[1..3]))[6]], "\n";
[(localtime timelocal(0, 0, 12, @{$_}[1..3]))[6]], "\n";
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 537: Line 537:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 546: Line 546:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #7060A8;">papply</span><span style="color: #0000FF;">({</span><span style="color: #000000;">1578</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1590</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1642</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1957</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2020</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2021</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2022</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2242</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2245</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2393</span><span style="color: #0000FF;">},</span><span style="color: #000000;">nyc</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">papply</span><span style="color: #0000FF;">({</span><span style="color: #000000;">1578</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1590</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1642</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1957</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2020</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2021</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2022</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2242</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2245</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2393</span><span style="color: #0000FF;">},</span><span style="color: #000000;">nyc</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
<small>Note the builtin timedate type does not officially support dates prior to ''1752''... the fact that the first three lines agree with other entries on this page is pure luck.</small>
<small>Note the builtin timedate type does not officially support dates prior to ''1752''... the fact that the first three lines agree with other entries on this page is pure luck.</small>
{{out}}
{{out}}
Line 563: Line 563:


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang pli>xmas_and_newyear: procedure options(main);
<syntaxhighlight lang="pli">xmas_and_newyear: procedure options(main);
day_name: procedure(year,month,day) returns(char(9) varying);
day_name: procedure(year,month,day) returns(char(9) varying);
declare days(0:6) char(9) varying;
declare days(0:6) char(9) varying;
Line 598: Line 598:
(F(2),A,F(2),A,F(4),A,A);
(F(2),A,F(2),A,F(4),A,A);
end;
end;
end xmas_and_newyear;</lang>
end xmas_and_newyear;</syntaxhighlight>
{{out}}
{{out}}
<pre>12/25/2021 is a Saturday
<pre>12/25/2021 is a Saturday
Line 604: Line 604:


=={{header|PL/M}}==
=={{header|PL/M}}==
<lang pli>100H:
<syntaxhighlight lang="pli">100H:
BDOS: PROCEDURE(F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
BDOS: PROCEDURE(F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; GO TO 0; END EXIT;
EXIT: PROCEDURE; GO TO 0; END EXIT;
Line 662: Line 662:
END;
END;
CALL EXIT;
CALL EXIT;
EOF</lang>
EOF</syntaxhighlight>
{{out}}
{{out}}
<pre>12/25/2021 IS A SATURDAY
<pre>12/25/2021 IS A SATURDAY
Line 668: Line 668:


=={{header|Python}}==
=={{header|Python}}==
<lang python>
<syntaxhighlight lang="python">
import datetime
import datetime


Line 681: Line 681:
nextNewYearDayAsString = weekDays[nextNewYearDay]
nextNewYearDayAsString = weekDays[nextNewYearDay]
print("Next new year is on a {}".format(nextNewYearDayAsString))
print("Next new year is on a {}".format(nextNewYearDayAsString))
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 691: Line 691:
<code>dayofweek</code> is defined at [[Day of the week#Quackery]].
<code>dayofweek</code> is defined at [[Day of the week#Quackery]].


<lang Quackery> [ [ table
<syntaxhighlight lang="quackery"> [ [ table
$ "Sun" $ "Mon"
$ "Sun" $ "Mon"
$ "Tues" $ "Wednes"
$ "Tues" $ "Wednes"
Line 703: Line 703:


2021 christmas day echo$ cr
2021 christmas day echo$ cr
2022 newyear's day echo$ cr</lang>
2022 newyear's day echo$ cr</syntaxhighlight>


{{out}}
{{out}}
Line 712: Line 712:


=={{header|Raku}}==
=={{header|Raku}}==
<lang perl6>my @d-o-w = < Sunday Monday Tuesday Wednesday Thursday Friday Saturday >;
<syntaxhighlight lang="raku" line>my @d-o-w = < Sunday Monday Tuesday Wednesday Thursday Friday Saturday >;


.say for (flat 2020..2022, (1500 .. 2500).roll(7)).sort.map: {
.say for (flat 2020..2022, (1500 .. 2500).roll(7)).sort.map: {
"In {$_}, New Years is on a { @d-o-w[Date.new($_, 1, 1).day-of-week % 7] }, " ~
"In {$_}, New Years is on a { @d-o-w[Date.new($_, 1, 1).day-of-week % 7] }, " ~
"and Christmas on a { @d-o-w[Date.new($_, 12, 25).day-of-week % 7] }."
"and Christmas on a { @d-o-w[Date.new($_, 12, 25).day-of-week % 7] }."
}</lang>
}</syntaxhighlight>
{{out|Sample output}}
{{out|Sample output}}
<pre>In 1578, New Years is on a Sunday, and Christmas on a Monday.
<pre>In 1578, New Years is on a Sunday, and Christmas on a Monday.
Line 731: Line 731:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>? "working..."
<syntaxhighlight lang="ring">? "working..."
weekdays = ["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
weekdays = ["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
dow = timelist()[15]
dow = timelist()[15]
Line 750: Line 750:


func nameof day
func nameof day
return weekdays[((day + today - 1) % 7) + 1] + "day"</lang>
return weekdays[((day + today - 1) % 7) + 1] + "day"</syntaxhighlight>
{{out}}
{{out}}
<pre>working...
<pre>working...
Line 759: Line 759:
=={{header|Ruby}}==
=={{header|Ruby}}==
This uses the same years as the Raku example. The Ruby Date class does however take the calendar reform (default 1582) into account, so the days for 1578 differ from all other languages so far.
This uses the same years as the Raku example. The Ruby Date class does however take the calendar reform (default 1582) into account, so the days for 1578 differ from all other languages so far.
<lang ruby>require 'date'
<syntaxhighlight lang="ruby">require 'date'


years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
Line 767: Line 767:
puts "In #{year}, New year's day is on a #{ny}, and Christmas day on #{xmas}."
puts "In #{year}, New year's day is on a #{ny}, and Christmas day on #{xmas}."
end
end
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>In 1578, New year's day is on a Wednesday, and Christmas day on Thursday.
<pre>In 1578, New year's day is on a Wednesday, and Christmas day on Thursday.
Line 786: Line 786:


The actual days for 1578 may have been different as the Gregorian calendar didn't start until 1582.
The actual days for 1578 may have been different as the Gregorian calendar didn't start until 1582.
<lang ecmascript>import "./date" for Date
<syntaxhighlight lang="ecmascript">import "./date" for Date


var years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
var years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
Line 793: Line 793:
var xmas = Date.new(year, 12, 25).weekDay
var xmas = Date.new(year, 12, 25).weekDay
System.print("In %(year), New year's day is on a %(newYear), and Christmas day on %(xmas).")
System.print("In %(year), New year's day is on a %(newYear), and Christmas day on %(xmas).")
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 810: Line 810:


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>func WeekDay(Year, Month, Day); \Return address of day of week
<syntaxhighlight lang="xpl0">func WeekDay(Year, Month, Day); \Return address of day of week
int Year, Month, Day; \Works for years 1583 onward
int Year, Month, Day; \Works for years 1583 onward
int DayOfWeek, Names;
int DayOfWeek, Names;
Line 823: Line 823:
Text(0, "This New Year's Day is on a ");
Text(0, "This New Year's Day is on a ");
Text(0, WeekDay(2022, 1, 1)); CrLf(0);
Text(0, WeekDay(2022, 1, 1)); CrLf(0);
]</lang>
]</syntaxhighlight>


{{out}}
{{out}}

Revision as of 23:08, 26 August 2022

Day of the week of Christmas and New Year is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


Determine programatically and show on this page on what weekday Christmas Day, 2021 and New Year's Day, 2022 will fall or did fall.

11l

Translation of: Python
V weekDays = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]
V thisXMas = Time(2021, 12, 25)
V thisXMasDay = Int(thisXMas.strftime(‘%w’))
V thisXMasDayAsString = weekDays[thisXMasDay]
print(‘This year's Christmas is on a ’thisXMasDayAsString)

V nextNewYear = Time(2022, 1, 1)
V nextNewYearDay = Int(nextNewYear.strftime(‘%w’))
V nextNewYearDayAsString = weekDays[nextNewYearDay]
print(‘Next new year is on a ’nextNewYearDayAsString)
Output:
This year's Christmas is on a Saturday
Next new year is on a Saturday

Ada

with Ada.Text_Io;
with Ada.Calendar.Formatting;

procedure Weekdays is
   use Ada.Text_Io;
   use Ada.Calendar.Formatting;

   subtype Time is Ada.Calendar.Time;

   procedure Info (Date : Time) is
   begin
      Put (Image (Date));
      Put (" is a ");
      Put (Day_Name'Image (Day_Of_Week (Date)));
      Put (".");
      New_Line;
   end Info;

   Christmas_Day : constant Time := Time_Of (Year => 2021, Month => 12, Day => 25);
   New_Years_Day : constant Time := Time_Of (Year => 2022, Month => 01, Day => 01);

begin
   Info (Christmas_Day);
   Info (New_Years_Day);
end Weekdays;
Output:
2021-12-25 00:00:00 is a SATURDAY.
2022-01-01 00:00:00 is a SATURDAY.

ALGOL W

Re-using code from the Day of the week task.

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.
Output:
25th of December 2021 is a Saturday
 1st of January  2022 is a Saturday

AutoHotkey

FormatTime, xmas , 20211225, dddd
FormatTime, newYear , 20220101, dddd
MsgBox % result := "Christmas Day, 2021 : " xmas "`nNew Year's Day, 2022 : " newYear
Output:
Christmas Day, 2021 : Saturday
New Year's Day, 2022 : Saturday

AWK

# syntax: GAWK -f WHAT_WEEKDAYS_WILL_CHRISTMAS_AND_NEW_YEAR.AWK
BEGIN {
    fmt = "%Y-%m-%d is a %A"
    print(strftime(fmt,mktime("2021 12 25 0 0 0")))
    print(strftime(fmt,mktime("2022 01 01 0 0 0")))
    print("")
    fmt = "%d %b %Y is %A"
    print(strftime(fmt,mktime("2021 12 25 0 0 0")))
    print(strftime(fmt,mktime("2022 01 01 0 0 0")))
    exit(0)
}
Output:
2021-12-25 is a Saturday
2022-01-01 is a Saturday

25 Dec 2021 is Saturday
01 Jan 2022 is Saturday

BASIC

10 DEFINT A-Z
20 DIM D$(6)
30 FOR I=0 TO 6: READ D$(I): NEXT
40 FOR I=1 TO 2
50 READ Y,M,D
60 PRINT USING "##/##/#### is a ";M;D;Y;
70 IF M<=2 THEN M=M+12: Y=Y-1
80 J=Y\100
90 K=Y MOD 100
100 D=(D+((M+1)*26)\10+K+K\4+J\4+5*J) MOD 7
110 PRINT D$(D)
120 NEXT
130 DATA Saturday,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday
140 DATA 2021,12,25
150 DATA 2022,1,1
Output:
12/25/2021 is a Saturday
 1/ 1/2022 is a Saturday

BCPL

get "libhdr"

let dayofweek(y,m,d) = valof
$(  let j, k = ?, ?
    if m<=2
    $(  m := m+12
        y := y-1
    $)
    j := y/100
    k := y rem 100
    d := (d + ((m+1)*26)/10 + k + k/4 + j/4 + 5*j) rem 7
    switchon d into
    $(  case 0: resultis "Saturday"
        case 1: resultis "Sunday"
        case 2: resultis "Monday"
        case 3: resultis "Tuesday"
        case 4: resultis "Wednesday"
        case 5: resultis "Thursday"
        case 6: resultis "Friday"
    $)
$)

let show(y,m,d) be
    writef("%N/%N/%N is a %S*N", m, d, y, dayofweek(y, m, d))

let start() be
$(  show(2021,12,25)
    show(2022,1,1)
$)
Output:
12/25/2021 is a Saturday
1/1/2022 is a Saturday

C

#define _XOPEN_SOURCE
#include <stdio.h>
#include <time.h>

int main() {
    struct tm t[2];
    strptime("2021-12-25", "%F", &t[0]);
    strptime("2022-01-01", "%F", &t[1]);
    for (int i=0; i<2; i++) {
        char buf[32];
        strftime(buf, 32, "%F is a %A", &t[i]);
        puts(buf);
    }
    return 0;
}
Output:
2021-12-25 is a Saturday
2022-01-01 is a Saturday

CLU

day_of_week = proc (d: date) returns (string)
    own days: array[string] := array[string]$
        [0:"Saturday", "Sunday", "Monday", "Tuesday", 
           "Wednesday", "Thursday", "Friday"]
    
    m: int := d.month
    y: int := d.year
    if m <= 2 then
        m := m + 12
        y := y - 1
    end
    j: int := y/100
    k: int := y//100
    dn: int := (d.day + ((m+1)*26)/10 + k + k/4 + j/4 + 5*j)//7
    return(days[dn])
end day_of_week

start_up = proc ()
    po: stream := stream$primary_output()
    days: array[date] := array[date]$
        [date$create(25, 12, 2021, 0, 0, 0),
         date$create( 1,  1, 2022, 0, 0, 0)]
    
    for d: date in array[date]$elements(days) do
        stream$putl(po, date$unparse_date(d) || " is a " || day_of_week(d))
    end
end start_up
Output:
25 December 2021 is a Saturday
1 January 2022 is a Saturday

COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. XMASNY.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WEEKDAYS.
          03 DAY-NAMES.
             05 FILLER   PIC X(9) VALUE "Saturday ".
             05 FILLER   PIC X(9) VALUE "Sunday   ".
             05 FILLER   PIC X(9) VALUE "Monday   ".
             05 FILLER   PIC X(9) VALUE "Tuesday  ".
             05 FILLER   PIC X(9) VALUE "Wednesday".
             05 FILLER   PIC X(9) VALUE "Thursday ".
             05 FILLER   PIC X(9) VALUE "Friday   ".
          03 DAYS        PIC X(9) OCCURS 7 TIMES,
                         REDEFINES DAY-NAMES.
       01 OUT-FMT.
          03 OUT-MONTH   PIC 99.
          03 FILLER      PIC X VALUE "/".
          03 OUT-DAY     PIC 99.
          03 FILLER      PIC X VALUE "/".
          03 OUT-YEAR    PIC 9(4).
          03 FILLER      PIC X(6) VALUE " is a ".
          03 OUT-DAYNAME PIC X(9).
       
       01 VARIABLES.
          03 CDATE.
             05 D-MONTH  PIC 99.
             05 D-DAY    PIC 99.
             05 D-YEAR   PIC 9999.
          03 ZELLER-DATA.
             05 M        PIC 99.
             05 Y        PIC 99.
             05 D        PIC 999.
             05 D7       PIC 999.
             05 J        PIC 99.
             05 K        PIC 99.
             05 DAY-NAME PIC X(9).
       
       PROCEDURE DIVISION.
       BEGIN.
           MOVE "25122021" TO CDATE.
           PERFORM SHOW-WEEKDAY.
           MOVE "01012022" TO CDATE.
           PERFORM SHOW-WEEKDAY.
           STOP RUN.
       
       SHOW-WEEKDAY.
           MOVE D-MONTH TO OUT-MONTH.
           MOVE D-DAY TO OUT-DAY.
           MOVE D-YEAR TO OUT-YEAR.
           PERFORM ZELLER.
           MOVE DAY-NAME TO OUT-DAYNAME.
           DISPLAY OUT-FMT.
       
       ZELLER.
           MOVE D-MONTH TO M.
           MOVE D-YEAR TO Y.
           IF M IS NOT GREATER THAN 2,
               ADD 12 TO M,
               SUBTRACT 1 FROM Y.
           DIVIDE Y BY 100 GIVING J.
           COMPUTE K = Y - J * 100.
           COMPUTE D = (M + 1) * 26.
           DIVIDE 10 INTO D.
           ADD K TO D.
           DIVIDE 4 INTO K.
           ADD K TO D.
           COMPUTE D = D + 5 * J.
           DIVIDE 4 INTO J.
           COMPUTE D = D + J + D-DAY.
           DIVIDE D BY 7 GIVING D7.
           MULTIPLY 7 BY D7.
           COMPUTE D = D - D7 + 1.
           MOVE DAYS(D) TO DAY-NAME.
Output:
25/12/2021 is a Saturday
01/01/2022 is a Saturday

Cowgol

include "cowgol.coh";

record Date is
    year: uint16;
    month: uint8;
    day: uint8;
end record;

sub DayName(date: [Date]): (name: [uint8]) is
    var days: [uint8][] := {
        "Saturday", "Sunday", "Monday", "Tuesday",
        "Wednesday", "Thursday", "Friday"
    };
    
    var m := date.month as uint16;
    var y := date.year;
    var d := date.day as uint16;
    
    if m <= 2 then
        m := m + 12;
        y := y - 1;
    end if;
    
    var j := y / 100;
    var k := y % 100;
    d := (d + ((m+1)*26)/10 + k + k/4 + j/4 + 5*j) % 7;
    name := days[d as @indexof days];
end sub;

sub printDate(date: [Date]) is
    print_i8(date.month);
    print_char('/');
    print_i8(date.day);
    print_char('/');
    print_i16(date.year);
end sub;

var dates: Date[] := {
    {2021, 25, 12},
    {2022, 1, 1}
};

var i: @indexof dates := 0;
while i < @sizeof dates loop
    printDate(&dates[i]);
    print(" is a ");
    print(DayName(&dates[i]));
    print_nl();
    i := i + 1;
end loop;
Output:
25/12/2021 is a Saturday
1/1/2022 is a Saturday

Draco

type Date = struct {
    word year; 
    byte month, day
};

proc nonrec day_name(Date date) *char:
    word m, y, d, j, k;
    m := date.month;
    y := date.year;
    d := date.day;
    if m <= 2 then
        m := m + 12;
        y := y - 1
    fi;
    j := y / 100;
    k := y % 100;
    d := (d + ((m+1)*26)/10 + k + (k>>2) + (j>>2) + 5*j) % 7;
    case d 
        incase 0: "Saturday"
        incase 1: "Sunday"
        incase 2: "Monday"
        incase 3: "Tuesday"
        incase 4: "Wednesday"
        incase 5: "Thursday"
        incase 6: "Friday"
    esac
corp

proc nonrec print_date(Date d) void:
    write(d.month, '/', d.day, '/', d.year)
corp

proc nonrec main() void:
    [2] Date dates = ((2021, 12, 25), (2022, 1, 1));
    byte i;    
    for i from 0 upto 1 do
        print_date(dates[i]);
        writeln(" is a ", day_name(dates[i]))
    od
corp
Output:
12/25/2021 is a Saturday
1/1/2022 is a Saturday

F#

// Show day of week for Christmas Day, 2021 and New Year's Day, 2022. Nigel Galloway: December 1st., 2021
printfn $"Christmas Day 2021 is a %s{string(System.DateTime(2021,12,25).DayOfWeek)}. New Years Day 2022 is a %s{string(System.DateTime(2022,1,1).DayOfWeek)}."
Output:
Christmas Day 2021 is a Saturday. New Years Day 2022 is a Saturday.

Factor

Works with: Factor version 0.99 2021-06-02
USING: calendar calendar.english calendar.holidays.us formatting
kernel sequences ;

CONSTANT: msg
    "In %d, New Years is on a %s, and Christmas is on a %s.\n"

: day-name ( ts -- str ) day-of-week day-names nth ;
: christmas ( n -- str ) christmas-day day-name ;
: new-years ( n -- str ) new-years-day day-name ;
: holidays ( n -- ny ch ) [ new-years ] [ christmas ] bi ;
: .holidays ( seq -- ) [ dup holidays msg printf ] each ;

{ 1578 1590 1642 1957 2020 2021 2022 2242 2245 2393 } .holidays
Output:
In 1578, New Years is on a Sunday, and Christmas is on a Monday.
In 1590, New Years is on a Monday, and Christmas is on a Tuesday.
In 1642, New Years is on a Wednesday, and Christmas is on a Thursday.
In 1957, New Years is on a Tuesday, and Christmas is on a Wednesday.
In 2020, New Years is on a Wednesday, and Christmas is on a Friday.
In 2021, New Years is on a Friday, and Christmas is on a Saturday.
In 2022, New Years is on a Saturday, and Christmas is on a Sunday.
In 2242, New Years is on a Saturday, and Christmas is on a Sunday.
In 2245, New Years is on a Wednesday, and Christmas is on a Thursday.
In 2393, New Years is on a Friday, and Christmas is on a Saturday.

FreeBASIC

#include "vbcompat.bi"       'contains functions for dealing with dates and times
#include "string.bi"         'contains functions for formatting text strings

dim as double christmas = DateSerial(2021, 12, 25)      'enter the dates of the two holidays
dim as double newyears  = DateSerial(2022, 01, 01)

print "Christmas Day 2021 is on a "; format(christmas,"dddd")
print "New Year's Day 2022 is on a "; format(newyears, "dddd")
Output:

Christmas Day 2021 is on a Saturday New Year's Day 2022 is on a Saturday

J

   (weekday 2021 12 25){::;:'Sun Mon Tue Wed Thu Fri Sat'
Sat
   (weekday 2022 01 01){::;:'Sun Mon Tue Wed Thu Fri Sat'
Sat

jq

Works with: jq

Works with gojq, the Go implementation of jq

Years, output format, and output are exactly as for Wren.

def weekdaynames:
  ["Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

# example: weekday(1999; 12; 25)
def weekday($year; $month; $day):
  "\($year)-\($month)-\($day)" | strptime("%Y-%m-%d") | weekdaynames[.[-2]];

1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393
| "In \(.), New year's day is on a \(weekday(.;1;1)), and Christmas day on \(weekday(.;12;25))."
Output:

As for #Wren

Julia

See also https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.format-Tuple{TimeType,%20AbstractString}

using Dates

for year in [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
    println("Year $year, New Years's Day: ", Dates.format(DateTime(year, 1, 1), "E, U d, Y"),
        " and Christmas: ", Dates.format(DateTime(year, 12, 25), "E, U d, Y"))
end
Output:
Year 1578, New Years's Day: Sunday, January 1, 1578 and Christmas: Monday, December 25, 1578
Year 1590, New Years's Day: Monday, January 1, 1590 and Christmas: Tuesday, December 25, 1590
Year 1642, New Years's Day: Wednesday, January 1, 1642 and Christmas: Thursday, December 25, 1642
Year 1957, New Years's Day: Tuesday, January 1, 1957 and Christmas: Wednesday, December 25, 1957
Year 2020, New Years's Day: Wednesday, January 1, 2020 and Christmas: Friday, December 25, 2020
Year 2021, New Years's Day: Friday, January 1, 2021 and Christmas: Saturday, December 25, 2021
Year 2022, New Years's Day: Saturday, January 1, 2022 and Christmas: Sunday, December 25, 2022
Year 2242, New Years's Day: Saturday, January 1, 2242 and Christmas: Sunday, December 25, 2242
Year 2245, New Years's Day: Wednesday, January 1, 2245 and Christmas: Thursday, December 25, 2245
Year 2393, New Years's Day: Friday, January 1, 2393 and Christmas: Saturday, December 25, 2393

ooRexx

/* REXX */
Call wkd 2021,12,25
Call wkd 2022,01,01
Exit
wkd:
Parse Arg y,m,d
wd=.Array~of('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')
dt=.DateTime~new(y,m,d)
say d'.'m'.'y 'is a' wd[dt~weekday]
Return
Output:
25.12.2021 is a Saturday
01.01.2022 is a Saturday<

Perl

#!/usr/bin/perl

use strict; # https://rosettacode.org/wiki/What_weekdays_will_Christmas_and_New_Year
use warnings;
use Time::Local;

for (
  ['Christmas 2021', 25, 11, 2021 ],
  ['New Years 2022', 1, 0, 2022 ],
  )
  {
  print "$_->[0] ", qw( Sunday Monday Tuesday Wednesday Thursday Fridat Saturday )
    [(localtime timelocal(0, 0, 12, @{$_}[1..3]))[6]], "\n";
  }
Output:
Christmas 2021 Saturday
New Years 2022 Saturday

Phix

with javascript_semantics
include timedate.e
procedure nyc(integer year)
    string ny = format_timedate({year,1,1,0,0,0},"Dddd"),
           cd = format_timedate({year,12,25,0,0,0},"Dddd")
    printf(1,"In %d, New year's day is on a %s, and Christmas day on a %s.\n",{year,ny,cd})
end procedure
papply({1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393},nyc)

Note the builtin timedate type does not officially support dates prior to 1752... the fact that the first three lines agree with other entries on this page is pure luck.

Output:
In 1578, New year's day is on a Sunday, and Christmas day on a Monday.
In 1590, New year's day is on a Monday, and Christmas day on a Tuesday.
In 1642, New year's day is on a Wednesday, and Christmas day on a Thursday.
In 1957, New year's day is on a Tuesday, and Christmas day on a Wednesday.
In 2020, New year's day is on a Wednesday, and Christmas day on a Friday.
In 2021, New year's day is on a Friday, and Christmas day on a Saturday.
In 2022, New year's day is on a Saturday, and Christmas day on a Sunday.
In 2242, New year's day is on a Saturday, and Christmas day on a Sunday.
In 2245, New year's day is on a Wednesday, and Christmas day on a Thursday.
In 2393, New year's day is on a Friday, and Christmas day on a Saturday.

PL/I

xmas_and_newyear: procedure options(main);
    day_name: procedure(year,month,day) returns(char(9) varying);
        declare days(0:6) char(9) varying;
        declare (year, month, day) fixed;
        declare (y, m, d, j, k) fixed;
        days(0) = 'Saturday';
        days(1) = 'Sunday';
        days(2) = 'Monday';
        days(3) = 'Tuesday';
        days(4) = 'Wednesday';
        days(5) = 'Thursday';
        days(6) = 'Friday';
        
        m = month;
        y = year;
        if m <= 2 then do;
            m = m + 12;
            y = y -1;
        end;
        j = y/100;
        k = mod(y,100);
        d = mod((day + ((m+1)*26)/10 + k + k/4 + j/4 + 5*j),7);
        return(days(d));
    end day_name;
    
    declare years(2)  fixed static initial(2021, 2022);
    declare months(2) fixed static initial(  12,    1);
    declare days(2)   fixed static initial(  25,    1);
    declare i fixed;
    do i=1 to 2;
        put skip edit(months(i),'/',days(i),'/',years(i),
                      ' is a ',
                      day_name(years(i),months(i),days(i)))
            (F(2),A,F(2),A,F(4),A,A);
    end;
end xmas_and_newyear;
Output:
12/25/2021 is a Saturday
 1/ 1/2022 is a Saturday

PL/M

100H:
BDOS: PROCEDURE(F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; GO TO 0; END EXIT;
PR$CH: PROCEDURE(C); DECLARE C BYTE; CALL BDOS(2,C); END PR$CH; 
PR$STR: PROCEDURE(S); DECLARE S ADDRESS; CALL BDOS(9,S); END PR$STR;

PR$NUM: PROCEDURE(N);
    DECLARE S(6) BYTE INITIAL ('.....$');
    DECLARE (N, P) ADDRESS, D BASED P BYTE;
    P = .S(5);
DIGIT:
    P = P-1;
    D = '0' + N MOD 10;
    IF (N := N/10) > 0 THEN GO TO DIGIT;
    CALL PR$STR(P);
END PR$NUM;

DAY$NAME: PROCEDURE(Y,M,D) ADDRESS;
    DECLARE (Y,M,D,J,K) ADDRESS;
    IF M <= 2 THEN DO;
        M = M + 12;
        Y = Y - 1;
    END;
    J = Y / 100;
    K = Y MOD 100;
    D = (D + ((M+1)*26)/10 + K + SHR(K,2) + SHR(J,2) + 5*6) MOD 7;
    DO CASE D;
        RETURN .'SATURDAY$';
        RETURN .'SUNDAY$';
        RETURN .'MONDAY$';
        RETURN .'TUESDAY$';
        RETURN .'WEDNESDAY$';
        RETURN .'THURSDAY$';
        RETURN .'FRIDAY$';
    END;
END DAY$NAME;

PR$DATE: PROCEDURE(Y,M,D);  
    DECLARE Y ADDRESS, (M, D) BYTE;
    CALL PR$NUM(M);
    CALL PR$CH('/');
    CALL PR$NUM(D);
    CALL PR$CH('/');
    CALL PR$NUM(Y);
END PR$DATE;

DECLARE YEARS(2)  ADDRESS INITIAL (2021, 2022);
DECLARE MONTHS(2) BYTE    INITIAL (  12,    1);
DECLARE DAYS(2)   BYTE    INITIAL (  25,    1);
DECLARE I BYTE;

DO I=0 TO 1;
    CALL PR$DATE(YEARS(I),MONTHS(I),DAYS(I));
    CALL PR$STR(.' IS A $');
    CALL PR$STR(DAY$NAME(YEARS(I),MONTHS(I),DAYS(I)));
    CALL PR$STR(.(13,10,'$'));
END;
CALL EXIT;
EOF
Output:
12/25/2021 IS A SATURDAY
1/1/2022 IS A SATURDAY

Python

import datetime

weekDays = ("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
thisXMas  = datetime.date(2021,12,25)
thisXMasDay = thisXMas.weekday()
thisXMasDayAsString = weekDays[thisXMasDay]
print("This year's Christmas is on a {}".format(thisXMasDayAsString))

nextNewYear = datetime.date(2022,1,1)
nextNewYearDay = nextNewYear.weekday()
nextNewYearDayAsString = weekDays[nextNewYearDay]
print("Next new year is on a {}".format(nextNewYearDayAsString))
Output:
This year's Christmas is on a Saturday
Next new year is on a Saturday

Quackery

dayofweek is defined at Day of the week#Quackery.

  [ [ table
      $ "Sun"   $ "Mon"
      $ "Tues"  $ "Wednes"
      $ "Thurs" $ "Fri"
      $ "Satur"  ]
    do $ "day" join ]        is day       ( n --> $ )

  [ 25 12 rot dayofweek ]    is christmas ( n --> $ )

  [ 1 1 rot dayofweek  ]     is newyear's ( n --> $ )

  2021 christmas day echo$ cr
  2022 newyear's day echo$ cr
Output:
Saturday
Saturday

Raku

my @d-o-w = < Sunday Monday Tuesday Wednesday Thursday Friday Saturday >;

.say for (flat 2020..2022, (1500 .. 2500).roll(7)).sort.map: {
     "In {$_}, New Years is on a { @d-o-w[Date.new($_,  1,  1).day-of-week % 7] }, " ~
     "and Christmas on a { @d-o-w[Date.new($_, 12, 25).day-of-week % 7] }."
}
Sample output:
In 1578, New Years is on a Sunday, and Christmas on a Monday.
In 1590, New Years is on a Monday, and Christmas on a Tuesday.
In 1642, New Years is on a Wednesday, and Christmas on a Thursday.
In 1957, New Years is on a Tuesday, and Christmas on a Wednesday.
In 2020, New Years is on a Wednesday, and Christmas on a Friday.
In 2021, New Years is on a Friday, and Christmas on a Saturday.
In 2022, New Years is on a Saturday, and Christmas on a Sunday.
In 2242, New Years is on a Saturday, and Christmas on a Sunday.
In 2245, New Years is on a Wednesday, and Christmas on a Thursday.
In 2393, New Years is on a Friday, and Christmas on a Saturday.

Ring

? "working..."
weekdays = ["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
dow = timelist()[15]
today = date()
tycd = "25/12/" + substr(today, 7, 4)
nnyd = "01/01/" + string(number(substr(today, 7, 4)) + 1)
for day = 0 to 366
  anotherday = adddays(today, day)
  if anotherday = tycd
    ? "This year's Christmas day is on a " + nameof(day) + "."
  ok
  if anotherday = nnyd
    ? "The next New Year's day is on a " + nameof(day) + "."
    exit
  ok
next
put "done..."

func nameof day
    return weekdays[((day + today - 1) % 7) + 1] + "day"
Output:
working...
This year's Christmas day is on a Saturday.
The next New Year's day is on a Saturday.
done...

Ruby

This uses the same years as the Raku example. The Ruby Date class does however take the calendar reform (default 1582) into account, so the days for 1578 differ from all other languages so far.

require 'date'

years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
years.each do |year|
  xmas = Date.new(year,12,25).strftime("%A")
  ny =   Date.new(year, 1, 1).strftime("%A")
  puts "In #{year}, New year's day is on a #{ny}, and Christmas day on #{xmas}."
end
Output:
In 1578, New year's day is on a Wednesday, and Christmas day on Thursday.
In 1590, New year's day is on a Monday, and Christmas day on Tuesday.
In 1642, New year's day is on a Wednesday, and Christmas day on Thursday.
In 1957, New year's day is on a Tuesday, and Christmas day on Wednesday.
In 2020, New year's day is on a Wednesday, and Christmas day on Friday.
In 2021, New year's day is on a Friday, and Christmas day on Saturday.
In 2022, New year's day is on a Saturday, and Christmas day on Sunday.
In 2242, New year's day is on a Saturday, and Christmas day on Sunday.
In 2245, New year's day is on a Wednesday, and Christmas day on Thursday.
In 2393, New year's day is on a Friday, and Christmas day on Saturday.

Wren

Library: Wren-date

This uses the same years as the Raku example.

The actual days for 1578 may have been different as the Gregorian calendar didn't start until 1582.

import "./date" for Date

var years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
for (year in years) {
    var newYear = Date.new(year, 1, 1).weekDay
    var xmas = Date.new(year, 12, 25).weekDay
    System.print("In %(year), New year's day is on a %(newYear), and Christmas day on %(xmas).") 
}
Output:
In 1578, New year's day is on a Sunday, and Christmas day on Monday.
In 1590, New year's day is on a Monday, and Christmas day on Tuesday.
In 1642, New year's day is on a Wednesday, and Christmas day on Thursday.
In 1957, New year's day is on a Tuesday, and Christmas day on Wednesday.
In 2020, New year's day is on a Wednesday, and Christmas day on Friday.
In 2021, New year's day is on a Friday, and Christmas day on Saturday.
In 2022, New year's day is on a Saturday, and Christmas day on Sunday.
In 2242, New year's day is on a Saturday, and Christmas day on Sunday.
In 2245, New year's day is on a Wednesday, and Christmas day on Thursday.
In 2393, New year's day is on a Friday, and Christmas day on Saturday.

XPL0

func    WeekDay(Year, Month, Day);      \Return address of day of week
int     Year, Month, Day;               \Works for years 1583 onward
int     DayOfWeek, Names;
[if     Month<=2 then [Month:= Month+12;  Year:= Year-1];
DayOfWeek:= rem((Day-1 + (Month+1)*26/10 + Year + Year/4 + Year/100*6 + Year/400)/7);
Names:= ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
return Names(DayOfWeek);
];      \WeekDay

[Text(0, "This Christmas is on a ");
Text(0, WeekDay(2021, 12, 25));  CrLf(0);
Text(0, "This New Year's Day is on a ");
Text(0, WeekDay(2022,  1,  1));  CrLf(0);
]
Output:
This Christmas is on a Saturday
This New Year's Day is on a Saturday