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

no edit summary
(Added AutoHotkey)
No edit summary
 
(17 intermediate revisions by 11 users not shown)
Line 8:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">V weekDays = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]
V thisXMas = Time(2021, 12, 25)
V thisXMasDay = Int(thisXMas.strftime(‘%w’))
Line 17:
V nextNewYearDay = Int(nextNewYear.strftime(‘%w’))
V nextNewYearDayAsString = weekDays[nextNewYearDay]
print(‘Next new year is on a ’nextNewYearDayAsString)</langsyntaxhighlight>
 
{{out}}
Line 26:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
with Ada.Calendar.Formatting;
 
Line 50:
Info (Christmas_Day);
Info (New_Years_Day);
end Weekdays;</langsyntaxhighlight>
{{out}}
<pre>
2021-12-25 00:00:00 is a SATURDAY.
2022-01-01 00:00:00 is a SATURDAY.
</pre>
 
=={{header|ALGOL 68}}==
{{Trans|ALGOL W}}
<syntaxhighlight lang="algol68">
BEGIN # find the day of the week 25/12/2021 and 01/01/2022 fall on #
[]STRING day name =
[]STRING( "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" )[ AT 0 ];
PROC day of week = ( INT d, m, y )INT:
BEGIN
INT mm := m;
INT yy := y;
IF mm <= 2 THEN
mm +:= 12;
yy -:= 1
FI;
INT j = yy OVER 100;
INT k = yy MOD 100;
( d + ( ( mm + 1 ) * 26 ) OVER 10 + k + k OVER 4 + j OVER 4 + 5 * j ) MOD 7
END # day of week # ;
print( ( "25th of December 2021 is a ", day name[ day of week( 25, 12, 2021 ) ], newline ) );
print( ( " 1st of January 2022 is a ", day name[ day of week( 1, 1, 2022 ) ], newline ) )
END
</syntaxhighlight>
{{out}}
<pre>
25th of December 2021 is a Saturday
1st of January 2022 is a Saturday
</pre>
 
=={{header|ALGOL W}}==
Re-using code from the [[Day of the week]] task.
<langsyntaxhighlight 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 );
Line 79 ⟶ 107:
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.</langsyntaxhighlight>
{{out}}
<pre>
Line 87 ⟶ 115:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">FormatTime, xmas , 20211225, dddd
FormatTime, newYear , 20220101, dddd
MsgBox % result := "Christmas Day, 2021 : " xmas "`nNew Year's Day, 2022 : " newYear</langsyntaxhighlight>
{{out}}
<pre>Christmas Day, 2021 : Saturday
Line 95 ⟶ 123:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f WHAT_WEEKDAYS_WILL_CHRISTMAS_AND_NEW_YEAR.AWK
BEGIN {
Line 107 ⟶ 135:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 118 ⟶ 146:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="gwbasic">10 DEFINT A-Z
20 DIM D$(6)
30 FOR I=0 TO 6: READ D$(I): NEXT
Line 132 ⟶ 160:
130 DATA Saturday,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday
140 DATA 2021,12,25
150 DATA 2022,1,1</langsyntaxhighlight>
{{out}}
<pre>12/25/2021 is a Saturday
1/ 1/2022 is a Saturday</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="freebasic">print "Christmas Day 2021 is on a "; diasemana$(2021, 12, 25)
print "New Year's Day 2022 is on a "; diasemana$(2022, 1, 1)
end
 
function diasemana$(anno, mes, dia)
dim nombre$(6)
nombre$ = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}
if mes <= 2 then
mes += 12
anno -= 1
end if
dia = (dia-1 + ((mes+1)*26)\10 + anno + anno\4 + anno\400 + anno*6\100) mod 7
return nombre$[dia]
end function</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|QBasic}}
{{trans|QBasic}}
<syntaxhighlight lang="qbasic">100 REM Day of the week of Christmas and New Year
110 CLS
120 DIM d$(6)
130 FOR i = 0 TO 6 : READ d$(i) : NEXT i
140 FOR i = 1 TO 2
150 READ y,m,d
160 PRINT m;"/";d;"/";y;" is a ";
170 IF m <= 2 THEN LET m = m+12 : LET y = y-1
180 LET j = INT(y/100)
190 LET k = y-INT(y/100)*100
200 LET t = (d+INT((m+1)*26)/10+k+k/4+j/4+5*j)
210 LET d = t-INT(t/7)*7
211 rem LET d = INT(d + ((m + 1) * 26) / 10 + K + K / 4 + J \ 4 + 5 * J) MOD 7
220 PRINT d$(d)
230 NEXT i
240 DATA "Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"
250 DATA 2021,12,25
260 DATA 2022,1,1
270 END</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
{{works with|MSX BASIC}}
{{works with|QBasic}}
{{trans|QBasic}}
<syntaxhighlight lang="qbasic">100 REM Day of the week of Christmas and New Year
110 CLS
120 DIM d$(6)
130 FOR i = 0 TO 6: READ d$(i): NEXT i
140 FOR i = 1 TO 2
150 READ y, m, d
160 PRINT USING "##/##/#### is a "; m; d; y;
170 IF m <= 2 THEN m = m + 12: y = y - 1
180 j = y \ 100
190 k = y MOD 100
200 d = (d + ((m + 1) * 26) \ 10 + k + k \ 4 + j \ 4 + 5 * j) MOD 7
210 PRINT d$(d)
220 NEXT i
230 DATA Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday
240 DATA 2021, 12, 25
250 DATA 2022, 1, 1
260 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">DIM d$(6)
FOR i = 0 TO 6: READ d$(i): NEXT i
FOR i = 1 TO 2
READ y, m, d
PRINT USING "##/##/#### is a "; m; d; y;
IF m <= 2 THEN m = m + 12: y = y - 1
J = y \ 100
K = y MOD 100
d = (d + ((m + 1) * 26) \ 10 + K + K \ 4 + J \ 4 + 5 * J) MOD 7
PRINT d$(d)
NEXT i
DATA Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday
DATA 2021, 12, 25
DATA 2022, 1, 1
END</syntaxhighlight>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">OPTION BASE 0
DIM d$(6)
FOR i = 0 TO 6
READ d$(i)
NEXT i
FOR i = 1 TO 2
READ y, m, d
PRINT USING "##/##/#### is a ": m, d, y;
IF m <= 2 THEN
LET m = m+12
LET y = y-1
END IF
LET j = IP(round(y)/100)
LET k = REMAINDER(ROUND(y),100)
LET d = REMAINDER(ROUND((d+IP(ROUND(((m+1)*26))/10)+k+IP(ROUND(k)/4)+IP(ROUND(j)/4)+5*j)),7)
PRINT d$(d)
NEXT i
DATA Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday
DATA 2021, 12, 25
DATA 2022, 1, 1
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="xbasic">PROGRAM "progname"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
DIM d$[6]
d$[0] = "Saturday"
d$[1] = "Sunday"
d$[2] = "Monday"
d$[3] = "Tuesday"
d$[4] = "Wednesday"
d$[5] = "Thursday"
d$[6] = "Friday"
 
y = 2021: m = 12: d = 25
FOR i = 1 TO 2
PRINT d; " /"; m; " /"; y; " is a ";
IF m <= 2 THEN m = m + 12: y = y - 1
J = y \ 100
K = y MOD 100
d = (d + ((m + 1) * 26) \ 10 + K + K \ 4 + J \ 4 + 5 * J) MOD 7
PRINT d$[d]
y = 2022: m = 1: d = 1
NEXT i
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">dim nombre$(6)
nombre$(0) = "Saturday"
nombre$(1) = "Sunday"
nombre$(2) = "Monday"
nombre$(3) = "Tuesday"
nombre$(4) = "Wednesday"
nombre$(5) = "Thursday"
nombre$(6) = "Friday"
 
print "Christmas Day 2021 is on a ", diasemana$(2021, 12, 25)
print "New Year's Day 2022 is on a ", diasemana$(2022, 1, 1)
end
 
sub diasemana$(anno, mes, dia)
if mes <= 2 then
mes = mes + 12
anno = anno - 1
fi
dia = mod((dia-1 + int(((mes+1)*26)/10) + anno + int(anno/4) + int(anno/400) + int(anno*6/100)), 7)
return nombre$(dia)
end sub</syntaxhighlight>
 
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let dayofweek(y,m,d) = valof
Line 166 ⟶ 356:
$( show(2021,12,25)
show(2022,1,1)
$)</langsyntaxhighlight>
{{out}}
<pre>12/25/2021 is a Saturday
Line 172 ⟶ 362:
 
=={{header|C}}==
<langsyntaxhighlight lang="c">#define _XOPEN_SOURCE
#include <stdio.h>
#include <time.h>
Line 186 ⟶ 376:
}
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>2021-12-25 is a Saturday
Line 192 ⟶ 382:
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">day_of_week = proc (d: date) returns (string)
own days: array[string] := array[string]$
[0:"Saturday", "Sunday", "Monday", "Tuesday",
Line 218 ⟶ 408:
stream$putl(po, date$unparse_date(d) || " is a " || day_of_week(d))
end
end start_up</langsyntaxhighlight>
{{out}}
<pre>25 December 2021 is a Saturday
Line 224 ⟶ 414:
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. XMASNY.
Line 298 ⟶ 488:
MULTIPLY 7 BY D7.
COMPUTE D = D - D7 + 1.
MOVE DAYS(D) TO DAY-NAME.</langsyntaxhighlight>
{{out}}
<pre>25/12/2021 is a Saturday
Line 304 ⟶ 494:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
 
record Date is
Line 353 ⟶ 543:
print_nl();
i := i + 1;
end loop;</langsyntaxhighlight>
{{out}}
<pre>25/12/2021 is a Saturday
1/1/2022 is a Saturday</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|Controls,SysUtils,StdCtrls}}
Delphi libraries make this easy.
 
<syntaxhighlight lang="Delphi">
 
procedure DoChristmasNewYear(Memo: TMemo);
var D: TDate;
begin
D:=EncodeDate(2021,12,25);
Memo.Lines.Add(FormatDateTime('"Christmas Day, 2021 is on: " dddd ', D));
D:=EncodeDate(2022,1,1);
Memo.Lines.Add(FormatDateTime('"New Years Day, 2022 is on: " dddd ', D));
end;
 
</syntaxhighlight>
{{out}}
<pre>
Christmas Day, 2021 is on: Saturday
New Years Day, 2022 is on: Saturday
 
</pre>
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">type Date = struct {
word year;
byte month, day
Line 398 ⟶ 612:
writeln(" is a ", day_name(dates[i]))
od
corp</langsyntaxhighlight>
{{out}}
<pre>12/25/2021 is a Saturday
1/1/2022 is a Saturday</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
func dayOfTheWeek year month day .
# Based on Conway's doomsday algorithm
century = floor (year / 100)
if century mod 4 = 0
centuryDoomsday = 2
elif century mod 4 = 1
centuryDoomsday = 0
elif century mod 4 = 2
centuryDoomsday = 5
elif century mod 4 = 3
centuryDoomsday = 3
.
mainYear = year mod 100
yearDoomsday = (floor (mainYear / 12) + mainYear mod 12 + floor (mainYear mod 12 / 4) + centuryDoomsday) mod 7
if mainYear = 0
if century mod 4 = 0
leap = 1
else
leap = 0
.
else
if mainYear mod 4 = 0
leap = 1
else
leap = 0
.
.
if leap = 1
januaryOne = (yearDoomsday + 4) mod 7
else
januaryOne = (yearDoomsday + 5) mod 7
.
monthDays[] = [ 0 31 59 90 120 151 181 212 243 273 304 334 ]
nthDay = monthDays[month]
if month > 2
nthDay += leap
.
nthDay += day
return (januaryOne + nthDay - 1) mod 7 + 1
.
days$[] = [ "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" ]
#
print "2021-12-25 is on " & days$[dayOfTheWeek 2021 12 25]
print "2022-1-1 is on " & days$[dayOfTheWeek 2022 1 1]
</syntaxhighlight>
{{out}}
<pre>
2021-12-25 is on Saturday
2022-1-1 is on Saturday
</pre>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// 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)}."
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 415 ⟶ 682:
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<langsyntaxhighlight lang="factor">USING: calendar calendar.english calendar.holidays.us formatting
kernel sequences ;
 
Line 427 ⟶ 694:
: .holidays ( seq -- ) [ dup holidays msg printf ] each ;
 
{ 1578 1590 1642 1957 2020 2021 2022 2242 2245 2393 } .holidays</langsyntaxhighlight>
{{out}}
<pre>
Line 443 ⟶ 710:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">#include "vbcompat.bi" 'contains functions for dealing with dates and times
#include "string.bi" 'contains functions for formatting text strings
 
Line 450 ⟶ 717:
 
print "Christmas Day 2021 is on a "; format(christmas,"dddd")
print "New Year's Day 2022 is on a "; format(newyears, "dddd")</langsyntaxhighlight>
{{out}}<pre>
Christmas Day 2021 is on a Saturday
Line 456 ⟶ 723:
</pre>
 
=={{header|J}}==
<syntaxhighlight lang="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</syntaxhighlight>
=={{header|jq}}==
{{works with|jq}}
Line 462 ⟶ 734:
Years, output format, and output are exactly as for [[#Wren|Wren]].
 
<langsyntaxhighlight lang="jq">def weekdaynames:
["Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
 
Line 470 ⟶ 742:
 
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))."</langsyntaxhighlight>
{{out}}
As for [[#Wren]]
 
 
=={{header|Julia}}==
See also https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.format-Tuple{TimeType,%20AbstractString}
<langsyntaxhighlight lang="julia">using Dates
 
for year in [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
Line 483 ⟶ 754:
" and Christmas: ", Dates.format(DateTime(year, 12, 25), "E, U d, Y"))
end
</langsyntaxhighlight>{{out}}
<pre>
Year 1578, New Years's Day: Sunday, January 1, 1578 and Christmas: Monday, December 25, 1578
Line 495 ⟶ 766:
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
</pre>
 
=={{header|Nim}}==
<syntaxhighlight lang="Nim">
import std/times
 
echo "25th of December 2021 is a ", getDayOfWeek(25, mDec, 2021)
echo "1st of January 2022 is a ", getDayOfWeek(1, mJan, 2022)
</syntaxhighlight>
 
{{out}}
<pre>25th of December 2021 is a Saturday
1st of January 2022 is a Saturday
</pre>
 
=={{header|ooRexx}}==
<langsyntaxhighlight lang="oorexx">/* REXX */
Call wkd 2021,12,25
Call wkd 2022,01,01
Line 507 ⟶ 791:
dt=.DateTime~new(y,m,d)
say d'.'m'.'y 'is a' wd[dt~weekday]
Return</langsyntaxhighlight>{{out}}
<pre>25.12.2021 is a Saturday
01.01.2022 is a Saturday<</pre>
 
=={{header|Pascal}}==
==={{header|Free Pascal}}===
<syntaxhighlight lang="pascal">
Program daysofweek;
Uses sysutils;
 
Const Years : array Of integer = (1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393);
 
Var christmasday, newyearsday : tdatetime;
year : integer;
Begin
For year In years Do
Begin
christmasday := encodeDate(year,12,25);
newyearsday := encodeDate(year,1,1);
writeln('in ',year,' New Years day is on ',DefaultFormatSettings.LongDayNames[DayOfWeek(
newyearsday)],', and Christmas day on a ',DefaultFormatSettings.LongDayNames[DayOfWeek(
christmasday
)]);
End;
End.
</syntaxhighlight>
{{out}}
<pre>
in 1578 New Years day is on Sunday, and Christmas day on a Monday
in 1590 New Years day is on Monday, and Christmas day on a Tuesday
in 1642 New Years day is on Wednesday, and Christmas day on a Thursday
in 1957 New Years day is on Tuesday, and Christmas day on a Wednesday
in 2020 New Years day is on Wednesday, and Christmas day on a Friday
in 2021 New Years day is on Friday, and Christmas day on a Saturday
in 2022 New Years day is on Saturday, and Christmas day on a Sunday
in 2242 New Years day is on Saturday, and Christmas day on a Sunday
in 2245 New Years day is on Wednesday, and Christmas day on a Thursday
in 2393 New Years day is on Friday, and Christmas day on a Saturday
</pre>
 
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/What_weekdays_will_Christmas_and_New_Year
Line 525 ⟶ 846:
print "$_->[0] ", qw( Sunday Monday Tuesday Wednesday Thursday Fridat Saturday )
[(localtime timelocal(0, 0, 12, @{$_}[1..3]))[6]], "\n";
}</langsyntaxhighlight>
{{out}}
<pre>
Line 533 ⟶ 854:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<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>
Line 542 ⟶ 863:
<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>
<!--</langsyntaxhighlight>-->
<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}}
Line 559 ⟶ 880:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">xmas_and_newyear: procedure options(main);
day_name: procedure(year,month,day) returns(char(9) varying);
declare days(0:6) char(9) varying;
Line 594 ⟶ 915:
(F(2),A,F(2),A,F(4),A,A);
end;
end xmas_and_newyear;</langsyntaxhighlight>
{{out}}
<pre>12/25/2021 is a Saturday
Line 600 ⟶ 921:
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="pli">100H:
BDOS: PROCEDURE(F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; GO TO 0; END EXIT;
Line 658 ⟶ 979:
END;
CALL EXIT;
EOF</langsyntaxhighlight>
{{out}}
<pre>12/25/2021 IS A SATURDAY
Line 664 ⟶ 985:
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">
import datetime
 
Line 677 ⟶ 998:
nextNewYearDayAsString = weekDays[nextNewYearDay]
print("Next new year is on a {}".format(nextNewYearDayAsString))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 687 ⟶ 1,008:
<code>dayofweek</code> is defined at [[Day of the week#Quackery]].
 
<langsyntaxhighlight Quackerylang="quackery"> [ [ table
$ "Sun" $ "Mon"
$ "Tues" $ "Wednes"
Line 699 ⟶ 1,020:
 
2021 christmas day echo$ cr
2022 newyear's day echo$ cr</langsyntaxhighlight>
 
{{out}}
Line 708 ⟶ 1,029:
 
=={{header|Raku}}==
<syntaxhighlight lang="raku" perl6line>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] }."
}</langsyntaxhighlight>
{{out|Sample output}}
<pre>In 1578, New Years is on a Sunday, and Christmas on a Monday.
Line 727 ⟶ 1,048:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">? "working..."
weekdays = ["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
dow = timelist()[15]
Line 746 ⟶ 1,067:
 
func nameof day
return weekdays[((day + today - 1) % 7) + 1] + "day"</langsyntaxhighlight>
{{out}}
<pre>working...
Line 752 ⟶ 1,073:
The next New Year's day is on a Saturday.
done...</pre>
 
=={{header|RPL}}==
{{works with|HP|48}}
≪ 1000000 / 25.12 + 0
TSTR 1 3 SUB
"X-MAS: " OVER +
"NEW YEAR: " ROT +
≫ '<span style="color:blue">TASK</span>' STO
 
2021 <span style="color:blue">TASK</span>
{{out}}
<pre>
2: "X-MAS: SAT"
1: "NEW YEAR: SAT"
</pre>
 
=={{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.
<langsyntaxhighlight lang="ruby">require 'date'
 
years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
Line 763 ⟶ 1,099:
puts "In #{year}, New year's day is on a #{ny}, and Christmas day on #{xmas}."
end
</syntaxhighlight>
</lang>
{{out}}
<pre>In 1578, New year's day is on a Wednesday, and Christmas day on Thursday.
Line 781 ⟶ 1,117:
This uses the same years as the Raku example.
 
The above module uses the Gregorian Proleptic calendar and therefore gives the wrong days of the week for 1578 as the earliest year for the adoption of the Gregorian calendar was 1582 when 10 days (from 5th until 14th October inclusive) were omitted. To get the correct days for 1578 (and agree with the Ruby entry) we therefore need to add 10 days to the Gregorian date which the ''Date.fromJulian'' method does automatically.
The actual days for 1578 may have been different as the Gregorian calendar didn't start until 1582.
<langsyntaxhighlight ecmascriptlang="wren">import "./date" for Date
 
System.print("Days of week per Gregorian Proleptic calendar:")
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).")
}
}</lang>
System.print("\nActual days for 1578 (Julian calendar) were 10 days later:")
System.print(" New Year's day was on %(Date.fromJulian(1578, 1, 1).weekDay), and Christmas day on %(Date.fromJulian(1578, 12, 25).weekDay).")</syntaxhighlight>
 
{{out}}
<pre>
Days of week per Gregorian Proleptic calendar:
In 1578, New year's day is on a Sunday, and Christmas day on Monday.
In 15901578, New year's day is on a MondaySunday, and Christmas day on TuesdayMonday.
In 16421590, New year's day is on a WednesdayMonday, and Christmas day on ThursdayTuesday.
In 19571642, New year's day is on a TuesdayWednesday, and Christmas day on WednesdayThursday.
In 20201957, New year's day is on a WednesdayTuesday, and Christmas day on FridayWednesday.
In 20212020, New year's day is on a FridayWednesday, and Christmas day on SaturdayFriday.
In 20222021, New year's day is on a SaturdayFriday, and Christmas day on SundaySaturday.
In 22422022, New year's day is on a Saturday, and Christmas day on Sunday.
In 22452242, New year's day is on a WednesdaySaturday, and Christmas day on ThursdaySunday.
In 23932245, New year's day is on a FridayWednesday, and Christmas day on SaturdayThursday.
In 2393, New year's day is on a Friday, and Christmas day on Saturday.
 
Actual days for 1578 (Julian calendar) were 10 days later:
New Year's day was on Wednesday, and Christmas day on Thursday.
</pre>
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">func WeekDay(Year, Month, Day); \Return address of day of week
int Year, Month, Day; \Works for years 1583 onward
int DayOfWeek, Names;
Line 819 ⟶ 1,162:
Text(0, "This New Year's Day is on a ");
Text(0, WeekDay(2022, 1, 1)); CrLf(0);
]</langsyntaxhighlight>
 
{{out}}
43

edits