Jump to content

Day of the week: Difference between revisions

m
syntax highlighting fixup automation
(Applesoft BASIC)
m (syntax highlighting fixup automation)
Line 15:
 
=={{header|11l}}==
<langsyntaxhighlight lang="11l">print((2008..2121).filter(y -> Time(y, 12, 25).strftime(‘%w’) == ‘0’))</langsyntaxhighlight>
{{out}}
<pre>
Line 24:
{{trans|REXX}}
The program uses two ASSIST macro (XDECO,XPRNT) to keep the code as short as possible.
<langsyntaxhighlight lang="360asm">* Day of the week 06/07/2016
DOW CSECT
USING DOW,R15 base register
Line 66:
PG DS CL12 buffer
YREGS
END DOW</langsyntaxhighlight>
{{out}}
<pre style="height:16ex"> 2011
Line 87:
 
=={{header|ABAP}}==
<langsyntaxhighlight ABAPlang="abap">report zday_of_week
data: lv_start type i value 2007,
lv_n type i value 114,
Line 111:
endif.
enddo.
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:30ex;overflow:scroll">
Line 136:
=={{header|Action!}}==
Action! does not have a standard library providing a day of week function, therefore an adaptation of [https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto.27s_methods Sakamoto's method] to determine the day of week for a given date using integer arithmetic is used.
<syntaxhighlight lang="action!">
<lang Action!>
Byte FUNC DayOfWeek(BYTE day, month CARD year BYTE century)
CARD weekday
Line 166:
OD
RETURN
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:30ex;overflow:scroll">
Line 190:
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Text_IO; use Ada.Text_IO;
Line 200:
end if;
end loop;
end Yuletide;</langsyntaxhighlight>
{{out}}
<pre style="height:30ex;overflow:scroll">
Line 228:
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d]}}
<langsyntaxhighlight lang="algol68"># example from: http://www.xs4all.nl/~jmvdveer/algol.html - GPL #
INT sun=0 # , mon=1, tue=2, wed=3, thu=4, fri=5, sat=6 #;
 
Line 250:
new line(stand out)
)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 258:
=={{header|ALGOL W}}==
{{Trans|Fortran}}
<langsyntaxhighlight lang="algolw">begin % find years where Christmas day falls on a Sunday %
integer procedure Day_of_week ( integer value d, m, y );
begin
Line 278:
if day = 1 then writeon( I_W := 5, S_W := 0, year );
end for_year
end.</langsyntaxhighlight>
{{out}}
<pre>
Line 285:
 
=={{header|ALGOL-M}}==
<langsyntaxhighlight lang="algol">
BEGIN
 
Line 326:
 
END
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 349:
</pre>
=={{header|APL}}==
<langsyntaxhighlight lang="apl">⍝ Based on the simplified calculation of Zeller's congruence, since Christmas is after March 1st, no adjustment is required.
⎕IO ← 0 ⍝ Indices are 0-based
y ← 2008 + ⍳114 ⍝ Years from 2008 to 2121
Line 356:
zeller ← { 7 | +/ (((1↑⍴⍵),6)⍴1 1 1 1 ¯1 1) × ⌊(((⍴⍵)⍴1 13 1)×⍵+(⍴⍵)⍴0 1 0)[;0 1 2 2 2 2]÷((1↑⍴⍵),6)⍴1 5 1 4 100 400 }
result ← (1 = zeller 25,[1]12,[0.5]y) / y
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 364:
 
=={{header|AppleScript}}==
<langsyntaxhighlight lang="applescript">set ChristmasSundays to {}
set Christmas to (current date)
set month of Christmas to December
Line 372:
if weekday of Christmas is Sunday then set end of ChristmasSundays to |year|
end repeat
ChristmasSundays</langsyntaxhighlight>
 
 
Or, composing generic functions:
<langsyntaxhighlight lang="applescript">
-- xmasIsSunday :: Int -> Bool
on xmasIsSunday(y)
Line 434:
end script
end if
end mReturn</langsyntaxhighlight>
{{Out}}
<langsyntaxhighlight AppleScriptlang="applescript">{2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067,
2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118}</langsyntaxhighlight>
 
=={{header|Arc}}==
<langsyntaxhighlight lang="arc">
(= day-names '(Sunday Monday Tuesday Wednesday Thursday Friday Saturday))
(= get-weekday-num (fn (year month day)
Line 449:
7)))
(= get-weekday-name (fn (weekday-num) (day-names weekday-num)))
</syntaxhighlight>
</lang>
<b>test:</b>
<langsyntaxhighlight lang="arc">(up i 2008 2121
(when (is 0 (get-weekday-num i 12 25))
(prn i)))
Line 473:
2118
 
</syntaxhighlight>
</lang>
 
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">print select 2008..2121 'year [
"Sunday" = get to :date.format:"dd-MM-YYYY" ~"25-12-|year|" 'Day
]</langsyntaxhighlight>
 
{{out}}
Line 486:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight lang="autohotkey">year = 2008
stop = 2121
 
Line 495:
year++
}
MsgBox,% out</langsyntaxhighlight>
 
=={{header|AutoIt}}==
<langsyntaxhighlight AutoItlang="autoit">#include <date.au3>
Const $iSunday = 1
For $iYear = 2008 To 2121 Step 1
Line 504:
ConsoleWrite(StringFormat($iYear & "\n"))
EndIf
Next</langsyntaxhighlight>
 
=={{header|AWK}}==
 
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f DAY_OF_THE_WEEK.AWK
# runtime does not support years > 2037 on my 32-bit Windows XP O/S
Line 517:
}
}
</syntaxhighlight>
</lang>
 
=={{header|BASIC}}==
Line 524:
This program needs the modulo function because there is a bug in the built in modulo function.
 
<langsyntaxhighlight BASIClang="basic">Declare Function modulo(x As Double, y As Double) As Double
Declare Function wd(m As Double, d As Double, y As Double) As Integer
 
Line 568:
Dec 25, 2107
Dec 25, 2112
Dec 25, 2118</langsyntaxhighlight>
 
==={{header|Applesoft BASIC}}===
{{trans|Commodore BASIC}}
<langsyntaxhighlight lang="gwbasic"> 1 DEF FN D7(N) = N - 7 * INT (N / 7)
2 DEF FN RD(Y) = 365 * Y + INT (Y / 4) - INT (Y / 100) + INT (Y / 400)
3 PRINT "YEARS WITH CHRISTMAS ON A SUNDAY" CHR$ (13)
4 FOR Y = 2008 TO 2121
5 IF NOT FN D7( FN RD(Y) - 6) THEN PRINT Y,
6 NEXT Y</langsyntaxhighlight>
==={{header|Atari BASIC}}===
{{trans|Commodore BASIC}}
<langsyntaxhighlight lang="basic">100 REM FIND YEARS WITH SUNDAY CHRISTMAS
110 PRINT CHR$(125);"SUNDAY CHRISTMASES 2008-2121:":PRINT
120 FOR Y=2008 TO 2121
Line 593:
210 PRINT
220 NEXT Y
230 IF FOUND THEN PRINT</langsyntaxhighlight>
 
{{Out}}
Line 606:
 
==={{header|BaCon}}===
<langsyntaxhighlight lang="freebasic">' Sunday Christmas
PRINT "Years with Christmas on a Sunday"
FOR y = 2008 TO 2121
tv = TIMEVALUE(y, 12, 25, 0, 0, 0)
IF WEEKDAY$(tv) = "Sunday" THEN PRINT y
NEXT</langsyntaxhighlight>
 
{{out}}
Line 637:
This takes advantage of the dynamic scope of arguments to DEF FN functions to nest definitions and ultimately turn the question "Does Christmas fall on a Sunday in year Y?" into a single Boolean function of the year number. It's easy to run afoul of stack limitations in Microsoft BASICs doing this, especially on older versions that just use the processor's 256-byte stack instead of giving BASIC its own, but this program runs fine even on an unexpanded VIC-20.
 
<langsyntaxhighlight lang="basic">100 REM FIND OUT WHAT YEARS HAVE CHRISTMAS ON A SUNDAY
110 REM MODULO FUNCTION (USES CALLER'S N AS DIVIDEND)
120 DEF FNNM(D) = N - D * INT(N/D)
Line 652:
230 : IF FNXS(Y) THEN PRINT Y,:REM PRINT YEARS IN COLUMNS
240 NEXT Y
250 PRINT</langsyntaxhighlight>
 
{{Out}}
Line 664:
 
==={{header|FreeBASIC}}===
<langsyntaxhighlight FreeBASIClang="freebasic">' version 17-06-2015
' compile with: fbc -s console
 
Line 687:
Print : Print "hit any key to end program"
Sleep
End</langsyntaxhighlight>
{{out}}
<pre>Dec 25 2011
Line 706:
Dec 25 2112
Dec 25 2118</pre>
<langsyntaxhighlight FreeBASIClang="freebasic">' version 17-06-2015
' Weekday And DateSerial only works with #Include "vbcompat.bi"
' compile with: fbc -s console
Line 722:
Print : Print "hit any key to end program"
Sleep
End</langsyntaxhighlight>
{{out}}
<pre>25-12-2011
Line 743:
 
==={{header|GW-BASIC}}===
<langsyntaxhighlight lang="gwbasic">10 M = 12
20 D = 25
30 FOR Y = 2007 TO 2122
Line 757:
150 Z = Z + D + INT((153*M + 8)/5)
160 Z = Z MOD 7
170 RETURN</langsyntaxhighlight>
 
==={{header|IS-BASIC}}===
<langsyntaxhighlight ISlang="is-BASICbasic">100 PROGRAM "Dayweek.bas"
110 PRINT "The years between 2008 and 2121 will the 25th of December be a Sunday:"
120 FOR Y=2008 TO 2121
Line 769:
170 LET W=D+INT((13*(M+12*A-2)-1)/5)+Y+INT(Y/4)-INT(Y/100)+INT(Y/400)
180 LET DAYWEEK=W-7*INT(W/7)
190 END DEF</langsyntaxhighlight>
 
==={{header|Minimal BASIC}}===
<langsyntaxhighlight lang="gwbasic">
10 REM Find years with Sunday Christmas
20 LET F = 2008
Line 787:
130 PRINT
140 END
</syntaxhighlight>
</lang>
 
==={{header|Sinclair ZX81 BASIC}}===
{{trans|C}}
Works with 1k of RAM. Follows the C code quite closely: the only factors that perhaps make it less readable are (a) the absence of a modulo operator and (b) the need for continual calls to <code>INT</code> because we don't have an integer type. The performance is pretty acceptable; seconds rather than minutes.
<langsyntaxhighlight lang="zxbasic"> 10 LET M=12
20 LET D=25
30 FOR Y=2008 TO 2121
Line 804:
110 LET W=D+INT ((13*MM-1)/5)+YY+INT (YY/4)-INT (YY/100)+INT (YY/400)
120 LET W=W-7*INT (W/7)
130 RETURN</langsyntaxhighlight>
{{out}}
<pre>2011
Line 831:
second, even in SLOW mode, as multiplying by 13 with a division by 5 is slower than by 256 alone, as well as that two divisions by
multiples of 100 are much slower than one by 16 as at the link. N.B. by relying on strings to have 4-digit years, this routine is not y10k-compliant
<langsyntaxhighlight lang="qbasic">
AUTO 100,10
Line 850:
 
ctrl+space
</syntaxhighlight>
</lang>
{{out}}
<pre>2011
Line 871:
 
==={{header|Tiny BASIC}}===
<langsyntaxhighlight lang="tinybasic">
LET Y = 2007
LET M = 12
Line 889:
LET Z = Z + D + (153*M + 8)/5
LET Z = Z - 7*(Z/7)
RETURN</langsyntaxhighlight>
{{out}}
<pre>2011
Line 910:
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">:: Day of the Week task from Rosetta Code
:: Batch File Implementation
:: Question: In what years between 2008 and 2121 will the 25th of December be a Sunday?
Line 930:
)
pause
exit /b 0</langsyntaxhighlight>
{{out}}
<pre>Dec 25, 2011 is a Sunday.
Line 953:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$+"DATELIB"
FOR year% = 2008 TO 2121
Line 959:
PRINT "Christmas Day is a Sunday in "; year%
ENDIF
NEXT</langsyntaxhighlight>
 
=={{header|bc}}==
Because ''bc'' has no date library, this program uses [http://mathforum.org/library/drmath/view/62324.html ''Zeller's rule''], also known as [http://www.merlyn.demon.co.uk/zel-like.htm ''Zeller's congruence''], to calculate day of week.
 
<langsyntaxhighlight lang="bc">scale = 0
 
/*
Line 985:
if (w(y, 12, 25) == 0) y
}
quit</langsyntaxhighlight>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let weekday(y, m, d) =
Line 999:
for year = 2008 to 2121
if weekday(year, 12, 25) = 0
do writef("%N*N", year)</langsyntaxhighlight>
{{out}}
<pre>2011
Line 1,022:
Befunge doesn't have any standard date-handling functionality, so we calculate the day of the week directly using a simple variation of the Zeller rule.
 
<langsyntaxhighlight lang="befunge">8 >:"2("*+::::4/+\"d"/-\45v
@_^#`"y": +1$<_v#%7+1+/*:*<
>:#,_>$:.55+,^ >0" ,52 ceD"</langsyntaxhighlight>
 
{{out}}
Line 1,047:
=={{header|Bracmat}}==
{{trans|C}}
<langsyntaxhighlight lang="bracmat">{ Calculate day of week in proleptic Gregorian calendar. Sunday == 0. }
( wday
= year month day adjustment mm yy
Line 1,073:
& 1+!y:?y
)
& done;</langsyntaxhighlight>
{{out}}
<pre>2011-12-25
Line 1,096:
Because of problems with various C libraries (such as ''time_t'' overflowing during 2038, or strptime() or mktime() not filling in ''tm_wday''), this program uses [http://mathforum.org/library/drmath/view/62324.html Zeller's Rule] to calculate day of week.
 
<langsyntaxhighlight lang="c">#include <stdio.h>
 
/* Calculate day of week in proleptic Gregorian calendar. Sunday == 0. */
Line 1,119:
 
return 0;
}</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">using System;
 
class Program
Line 1,137:
}
}
}</langsyntaxhighlight>
 
Using LINQ:
<langsyntaxhighlight lang="csharp">using System;
using System.Linq;
 
Line 1,154:
foreach (string day in days) Console.WriteLine(day);
}
}</langsyntaxhighlight>Lambda expressions FTW:
<langsyntaxhighlight lang="csharp">using System;
using System.Linq;
 
Line 1,167:
.ForEach(ent => Console.WriteLine(ent.ToString("dd MMM yyyy")));
}
}</langsyntaxhighlight>
{{out}}
<pre style="height:20ex;overflow:scroll">25 Dec 2011
Line 1,188:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
 
Line 1,205:
std::cout << "\n" ;
return 0 ;
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,231:
Utilizing Java interop
 
<langsyntaxhighlight lang="clojure">
(import '(java.util GregorianCalendar))
(defn yuletide [start end]
Line 1,239:
 
(yuletide 2008 2121)
</syntaxhighlight>
</lang>
<pre>(2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118)</pre>
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">weekday = proc (d: date) returns (int)
y: int := d.year
m: int := d.month
Line 1,263:
end
end
end start_up</langsyntaxhighlight>
{{out}}
<pre>2011
Line 1,285:
=={{header|COBOL}}==
Using Date Intrinsic Functions
<syntaxhighlight lang="cobol">
<lang COBOL>
program-id. dec25.
data division.
Line 1,308:
.
end program dec25.
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:20ex;overflow:scroll">
Line 1,332:
Without Date Intrinsic Functions
 
<syntaxhighlight lang="cobol">
<lang Cobol>
identification division.
program-id. dowtest.
Line 1,401:
.
end program todow.
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:20ex;overflow:scroll">
Line 1,424:
 
=={{header|CoffeeScript}}==
<langsyntaxhighlight lang="coffeescript">december = 11 # gotta love Date APIs :)
sunday = 0
for year in [2008..2121]
xmas = new Date year, december, 25
console.log year if xmas.getDay() is sunday</langsyntaxhighlight>one-liner:<syntaxhighlight lang ="coffeescript">console.log year for year in [2008...2121] when new Date(year, 11, 25).getDay() is 0</langsyntaxhighlight>
{{out}}
<pre style="height:20ex;overflow:scroll">
Line 1,451:
 
=={{header|ColdFusion}}==
<syntaxhighlight lang="coldfusion">
<lang ColdFusion>
<cfloop from = "2008" to = "2121" index = "i">
<cfset myDate = createDate(i, 12, 25) />
Line 1,458:
</cfif>
</cfloop>
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(loop for year from 2008 upto 2121
when (= 6 (multiple-value-bind
(second minute hour date month year day-of-week dst-p tz)
Line 1,467:
(declare (ignore second minute hour date month year dst-p tz))
day-of-week))
collect year)</langsyntaxhighlight>
 
<langsyntaxhighlight lang="lisp">(loop for year from 2008 upto 2121
for xmas = (encode-universal-time 0 0 0 25 12 year)
for day = (nth-value 6 (decode-universal-time xmas))
when (= day 6) collect year)</langsyntaxhighlight>
 
=={{header|Component Pascal}}==
{{Works with|BlackBox Component Builder}}
<langsyntaxhighlight lang="oberon2">
MODULE DayOfWeek;
IMPORT DevCommanders, TextMappers, Dates, StdLog;
Line 1,514:
 
END DayOfWeek.
</syntaxhighlight>
</lang>
Execute: ^Q DayOfWeek.Do 2008 2121~
{{out}}
Line 1,538:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
 
sub weekday(year: uint16, month: uint8, day: uint8): (wd: uint8) is
Line 1,561:
end if;
year := year + 1;
end loop;</langsyntaxhighlight>
{{out}}
<pre>2011
Line 1,583:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">void main() {
import std.stdio, std.range, std.algorithm, std.datetime;
 
Line 1,589:
iota(2008, 2122)
.filter!(y => Date(y, 12, 25).dayOfWeek == DayOfWeek.sun));
}</langsyntaxhighlight>
{{out}}
<pre>Christmas comes on a Sunday in the years:
Line 1,596:
=={{header|Delphi}}==
{{libheader|sysutils}} always in uses clause in Delphi
<langsyntaxhighlight lang="delphi">procedure IsXmasSunday(fromyear, toyear: integer);
var
i: integer;
Line 1,615:
//GUI
form1.label1.caption := outputyears;
end;</langsyntaxhighlight>
 
Procedure called with year range to test and outputs a space-delimited array of years to a label. There is no error check that fromyear < toyear, but this is easily added.
Line 1,625:
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">proc nonrec weekday(word y, m, d) byte:
word c;
if m<3 then
Line 1,645:
fi
od
corp</langsyntaxhighlight>
{{out}}
<pre>2011
Line 1,666:
 
=={{header|ECL}}==
<langsyntaxhighlight ECLlang="ecl">//In what years between 2008 and 2121 will the 25th of December be a Sunday?
 
IMPORT STD;
Line 1,705:
2118
*/
</syntaxhighlight>
</lang>
This code solves a specific task, but can easily be modified as a generic function to return the DayOfWeek for any day after 1 AD.
 
=={{header|Elixir}}==
{{works with|Elixir|1.4}}
<langsyntaxhighlight lang="elixir">Enum.each(2008..2121, fn year ->
wday = Date.from_erl!({year, 12, 25}) |> Date.day_of_week
if wday==7, do: IO.puts "25 December #{year} is sunday"
end)</langsyntaxhighlight>
 
{{out}}
Line 1,737:
 
=={{header|Emacs Lisp}}==
<langsyntaxhighlight lang="lisp">(require 'calendar)
 
(defun sunday-p (y)
Line 1,747:
(seq-filter #'sunday-p (number-sequence a b)))
 
(print (xmas-sunday 2008 2121))</langsyntaxhighlight>
{{output}}
<pre>(2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118)</pre>
Line 1,753:
=={{header|Erlang}}==
 
<langsyntaxhighlight lang="erlang">% Implemented by bengt kleberg
-module(yuletide).
-export([main/0, sunday_years/2]).
Line 1,764:
 
is_sunday( 7 ) -> true;
is_sunday( _ ) -> false.</langsyntaxhighlight>
{{out}}
<pre>
Line 1,787:
 
=={{header|ERRE}}==
<syntaxhighlight lang="erre">
<lang ERRE>
PROGRAM DAY_OF_THE_WEEK
 
Line 1,817:
GET(K$)
END PROGRAM
</syntaxhighlight>
</lang>
{{out}}
<pre>Dec 25, 2011
Line 1,839:
 
=={{header|Euphoria}}==
<syntaxhighlight lang="euphoria">
<lang Euphoria>
--Day of the week task from Rosetta Code wiki
--User:Lnettnay
Line 1,855:
end if
end for
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,878:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">open System
 
[ 2008 .. 2121 ]
|> List.choose (fun y -> if DateTime(y,12,25).DayOfWeek = DayOfWeek.Sunday then Some(y) else None)
|> printfn "%A"</langsyntaxhighlight>
{{out}}
<pre>[2011; 2016; 2022; 2033; 2039; 2044; 2050; 2061; 2067; 2072; 2078; 2089; 2095;
Line 1,888:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: calendar math.ranges prettyprint sequences ;
2008 2121 [a,b] [ 12 25 <date> sunday? ] filter .</langsyntaxhighlight>
 
=={{header|FBSL}}==
<langsyntaxhighlight lang="qbasic">#APPTYPE CONSOLE
 
'In what years between 2008 and 2121 will the 25th of December be a Sunday?
Line 1,904:
next
PAUSE
</syntaxhighlight>
</lang>
 
=={{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.
<langsyntaxhighlight lang="forth">
\ Zeller's Congruence
: weekday ( d m y -- wd) \ 1 mon..7 sun
Line 1,926:
7 = if i . then
loop cr ;
</syntaxhighlight>
</lang>
 
<langsyntaxhighlight lang="forth">
cr yuletide
December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
ok
</syntaxhighlight>
</lang>
 
 
To show year-2100 problems with SwiftForth's provided Modified Julian Day support:
 
<langsyntaxhighlight lang="forth">: yuletide
." December 25 is Sunday in "
2122 2008 do
Line 1,945:
 
cr yuletide
December 25 is Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2100 2106 2117</langsyntaxhighlight>
 
In [[4tH]] a library is available which provides the right answer:
 
<langsyntaxhighlight lang="forth">include lib/time.4th
 
: yuletide
Line 1,958:
loop cr ;
 
cr yuletide</langsyntaxhighlight>
 
The code is derived from "Collected Algorithms from ACM", Volume 1 Algorithms 1-220.
Line 1,965:
{{works with|Fortran|90 and later}}
Based on Forth example
<langsyntaxhighlight lang="fortran">PROGRAM YULETIDE
IMPLICIT NONE
Line 1,994:
END FUNCTION Day_of_week
END PROGRAM YULETIDE</langsyntaxhighlight>
{{out}}
<pre>
Line 2,009:
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">for y = 2008 to 2121
if (parseDate["$y-12-25"] -> ### u ###) == "7"
println[y]</langsyntaxhighlight>
 
{{out}}
Line 2,035:
 
=={{header|FutureBasic}}==
<langsyntaxhighlight lang="futurebasic">window 1
 
long y
Line 2,058:
next
 
HandleEvents</langsyntaxhighlight>
 
 
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=b9b4e9a871e96ea6f1db467fa23669fe Click this link to run this code]'''
<langsyntaxhighlight lang="gambas">Public Sub Main()
Dim siCount As Short
 
Line 2,070:
Next
 
End</langsyntaxhighlight>
Output:
<pre>
Line 2,093:
 
=={{header|GAP}}==
<langsyntaxhighlight lang="gap">Filtered([2008 .. 2121], y -> WeekDay([25, 12, y]) = "Sun");
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]
 
Line 2,115:
 
Filtered([2008 .. 2121], y -> WeekDayAlt([25, 12, y]) = "Sun");
# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ]</langsyntaxhighlight>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 2,130:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 2,155:
 
Solution:
<langsyntaxhighlight lang="groovy">def yuletide = { start, stop -> (start..stop).findAll { Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" } }</langsyntaxhighlight>
 
Test program:
<syntaxhighlight lang ="groovy">println yuletide(2008, 2121)</langsyntaxhighlight>
 
{{out}}
Line 2,165:
=={{header|Haskell}}==
Using the time library:
<langsyntaxhighlight lang="haskell">import Data.Time (fromGregorian)
import Data.Time.Calendar.WeekDate (toWeekDate)
 
Line 2,184:
| year <- [2008 .. 2121],
isXmasSunday year
]</langsyntaxhighlight>
{{out}}
<pre>Sunday 25 December 2011
Line 2,205:
 
The built-in System.Time module can overflow at the Unix epoch in 2038:
<langsyntaxhighlight lang="haskell">import System.Time
isXmasSunday :: Int -> Bool
Line 2,233:
[ "25 December " ++ show year ++ " is Sunday"
| year <- [2008 .. 2121]
, isXmasSunday year ]</langsyntaxhighlight>
{{out}} on 32-bit machine:
<pre>
Line 2,263:
 
=={{header|HicEst}}==
<langsyntaxhighlight HicEstlang="hicest">DO year = 1, 1000000
TIME(Year=year, MOnth=12, Day=25, TO, WeekDay=weekday)
IF( weekday == 7) WRITE(StatusBar) year
ENDDO
 
END</langsyntaxhighlight>
<pre>No anomalies detected for the first million years :-)
Dec 25 = Sunday in
Line 2,277:
=={{header|Icon}} and {{header|Unicon}}==
 
<langsyntaxhighlight Iconlang="icon">link datetime
 
procedure main()
writes("December 25th is a Sunday in: ")
every writes((dayoweek(25,12,y := 2008 to 2122)=="Sunday",y)," ")
end</langsyntaxhighlight>
 
 
Line 2,288:
[http://www.cs.arizona.edu/icon/library/src/procs/datetime.icn datetime provides dayoweek]
 
<langsyntaxhighlight Iconlang="icon">procedure dayoweek(day, month, year) #: day of the week
static d_code, c_code, m_code, ml_code, y, C, M, Y
 
Line 2,330:
return d_code[(C + Y + M + day) % 7 + 1]
end</langsyntaxhighlight>
 
{{out}}
Line 2,336:
 
=={{header|J}}==
<langsyntaxhighlight lang="j"> load 'dates' NB. provides verb 'weekday'
xmasSunday=: #~ 0 = [: weekday 12 25 ,~"1 0 ] NB. returns years where 25 Dec is a Sunday
xmasSunday 2008 + i.114 NB. check years from 2008 to 2121
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</langsyntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
Line 2,356:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>Sun Dec 25 00:00:00 CST 2011
Line 2,380:
===ES5===
====Iteration====
<langsyntaxhighlight lang="javascript">for (var year = 2008; year <= 2121; year++){
var xmas = new Date(year, 11, 25)
if ( xmas.getDay() === 0 )
console.log(year)
}</langsyntaxhighlight>
{{out}}
<pre>2011
Line 2,406:
====Functional composition====
 
<langsyntaxhighlight JavaScriptlang="javascript">(function () {
'use strict';
 
Line 2,426:
.filter(isXmasSunday);
 
})();</langsyntaxhighlight>
 
{{Out}}
Line 2,433:
 
===ES6===
<langsyntaxhighlight JavaScriptlang="javascript">(() => {
"use strict";
 
Line 2,463:
// MAIN ---
return main();
})();</langsyntaxhighlight>
{{Out}}
<langsyntaxhighlight JavaScriptlang="javascript">[2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]</langsyntaxhighlight>
 
=={{header|jq}}==
<langsyntaxhighlight lang="jq"># Use Zeller's Congruence to determine the day of the week, given
# year, month and day as integers in the conventional way.
# If iso == "iso" or "ISO", then emit an integer in 1 -- 7 where
Line 2,485:
| if iso == "iso" or iso == "ISO" then 1 + ((. + 5) % 7)
else . % 7
end;</langsyntaxhighlight>
'''The task''':
<langsyntaxhighlight lang="jq"># Give the results as an array so they can
# readily be presented on a single line:
[range(2008; 2122) | select( day_of_week(.;12;25;0) == 1 )]</langsyntaxhighlight>
{{out}}
$ jq -n -c -f zeller.jq
Line 2,497:
Jsi does not yet implement the Javascript ''Date'' object. ''strftime' and ''strptime'' functions are used here instead.
 
<langsyntaxhighlight lang="javascript">/* Day of the week, December 25th on a Sunday */
for (var year = 2008; year <= 2121; year++) {
var xmas = strptime(year + '/12/25', '%Y/%m/%d');
Line 2,524:
2118
=!EXPECTEND!=
*/</langsyntaxhighlight>
 
{{out}}
Line 2,531:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Dates
 
lo, hi = 2008, 2121
Line 2,540:
 
println("Years from $lo to $hi having Christmas on Sunday: ")
foreach(println, year.(xmas))</langsyntaxhighlight>
 
{{out}}
Line 2,563:
 
=={{header|K}}==
<langsyntaxhighlight Klang="k"> wd:{(__jd x)!7} / Julian day count, Sun=6
y@&6={wd 1225+x*10000}'y:2008+!114
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">// version 1.0.6
 
import java.util.*
Line 2,580:
calendar.add(Calendar.YEAR, 1)
}
}</langsyntaxhighlight>
 
{{out}}
Line 2,606:
 
=={{header|Lasso}}==
<langsyntaxhighlight lang="lasso">loop(-From=2008, -to=2121) => {^
local(tDate = date('12/25/' + loop_count))
#tDate->dayOfWeek == 1 ? '\r' + #tDate->format('%D') + ' is a Sunday'
^}</langsyntaxhighlight>
 
{{out}}
Line 2,631:
 
=={{header|Liberty BASIC}}==
<langsyntaxhighlight lang="lb"> count = 0
for year = 2008 to 2121
dateString$="12/25/";year
Line 2,644:
 
print count; " years when Christmas Day falls on a Sunday"
end</langsyntaxhighlight>
 
=={{header|Lingo}}==
<langsyntaxhighlight lang="lingo">put "December 25 is a Sunday in:"
refDateObj = date(1905,1,2)
repeat with year = 2008 to 2121
Line 2,653:
dayOfWeek = ((dateObj - refDateObj) mod 7)+1 -- 1=Monday..7=Sunday
if dayOfWeek=7 then put year
end repeat</langsyntaxhighlight>
{{out}}
<pre>
Line 2,677:
 
=={{header|LiveCode}}==
<langsyntaxhighlight LiveCodelang="livecode">function xmasSunday startDate endDate
convert the long date to dateitems
put it into xmasDay
Line 2,689:
if the last char of xmasYear is comma then delete the last char of xmasYear
return xmasYear
end xmasSunday</langsyntaxhighlight>Example<syntaxhighlight lang LiveCode="livecode">put xmasSunday(2008,2121)</langsyntaxhighlight>Output<pre>2011,2016,2022,2033,2039,2044,2050,2061,2067,2072,2078,2089,2095,2101,2107,2112,2118</pre>
 
=={{header|Logo}}==
<langsyntaxhighlight Logolang="logo">; Determine if a Gregorian calendar year is leap
to leap? :year
output (and
Line 2,725:
; Put it all together to answer the question posed in the problem
print filter [sunday? ? 12 25] iseq 2008 2121
bye</langsyntaxhighlight>
 
{{Out}}
Line 2,733:
'''Library:''' [http://luaforge.net/projects/date/ LuaDate]
 
<langsyntaxhighlight Lualang="lua">require("date")
 
for year=2008,2121 do
Line 2,739:
print(year)
end
end</langsyntaxhighlight>
 
{{out}}
Line 2,764:
=== Without external modules ===
Same output as above
<langsyntaxhighlight Lualang="lua">local dTab = {day = 25, month = 12}
for year = 2008, 2121 do
dTab.year = year
Line 2,770:
print(year)
end
end</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
Str$( number, format$) use Visual Basic 6 format
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Print "December 25 is a Sunday in:"
For Year=2008 to 2121 {
Line 2,790:
 
 
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,813:
 
=={{header|M4}}==
<langsyntaxhighlight M4lang="m4">divert(-1)
 
define(`for',
Line 2,831:
 
for(`yr',2008,2121,
`ifelse(eval(julianxmas(yr)%7==6),1,`yr ')')</langsyntaxhighlight>
 
{{out}}
Line 2,840:
 
=={{header|Maple}}==
<langsyntaxhighlight Maplelang="maple">xmas:= proc()
local i, dt;
for i from 2008 to 2121 by 1 do
Line 2,850:
end proc;
 
xmas();</langsyntaxhighlight>
 
{{Out|Output}}
Line 2,875:
Or simply:
 
<langsyntaxhighlight lang="maple">select(y->Calendar:-DayOfWeek(Date(y,12,25))=1,[$2008..2121]);</langsyntaxhighlight>
 
{{out}}
Line 2,881:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Reap[If[DateString[{#,12,25},"DayName"]=="Sunday",Sow[#]]&/@Range[2008,2121]][[2,1]]</langsyntaxhighlight>
gives back:
<langsyntaxhighlight Mathematicalang="mathematica">{2011,2016,2022,2033,2039,2044,2050,2061,2067,2072,2078,2089,2095,2101,2107,2112,2118}</langsyntaxhighlight>
 
=={{header|MATLAB}} / {{header|Octave}}==
 
<langsyntaxhighlight Matlablang="matlab"> t = datenum([[2008:2121]',repmat([12,25,0,0,0], 2121-2007, 1)]);
t = t(strmatch('Sunday', datestr(t,'dddd')), :);
datestr(t,'yyyy')
</syntaxhighlight>
</lang>
 
 
Line 2,915:
 
=={{header|Maxima}}==
<langsyntaxhighlight lang="maxima">weekday(year, month, day) := block([m: month, y: year, k],
if m < 3 then (m: m + 12, y: y - 1),
k: 1 + remainder(day + quotient((m + 1)*26, 10) + y + quotient(y, 4)
Line 2,924:
sublist(makelist(i, i, 2008, 2121),
lambda([y], weekday(y, 12, 25) = 'sunday));
/* [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118] */</langsyntaxhighlight>
 
=={{header|МК-61/52}}==
<syntaxhighlight lang="text">П9 7 П7 1 П8 НОП ИП8 2 2 -
1 0 / [x] П6 ИП9 + 1 8 9
9 - 3 6 5 , 2 5 * [x]
Line 2,933:
0 , 5 9 * [x] + 2 9 +
ИП7 + П4 ИП4 7 / [x] 7 * -
x=0 64 ИП9 С/П ИП9 1 + П9 БП 06</langsyntaxhighlight>
 
''Input:'' РX: starting year.
Line 2,945:
Consequently, it suffers from the same problem as C.
 
<langsyntaxhighlight lang="modula3">MODULE Yule EXPORTS Main;
 
IMPORT IO, Fmt, Date, Time;
Line 2,972:
END;
END;
END Yule.</langsyntaxhighlight>
 
{{out}}
Line 2,985:
=={{header|MUMPS}}==
{{libheader|VA Kernel|22.0}}
<syntaxhighlight lang="mumps">
<lang MUMPS>
DOWHOLIDAY
;In what years between 2008 and 2121 will December 25 be a Sunday?
Line 3,005:
KILL BDT,EDT,CHECK,CHKFOR,LIST,I,X,Y
QUIT
</langsyntaxhighlight>Usage:<pre>USER>D ^DOW
The following years have Christmas on a Sunday: 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118
Line 3,011:
 
=={{header|Nanoquery}}==
<langsyntaxhighlight Nanoquerylang="nanoquery">import Nanoquery.Util
// loop through the years 2008 through 2121
Line 3,018:
println "In " + year + ", December 25th is a Sunday."
end if
end for</langsyntaxhighlight>
 
=={{header|NetRexx}}==
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
 
Line 3,039:
 
return
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,047:
===Comparison of Some Common Day-of-Week Algorithms===
The following program exercises some common &quot;Day-0f-Week&quot; algorithms to confirm they all arrive at the same result.
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
 
Line 3,238:
method modulo(N = int, D = int) inheritable static binary returns int
return (D + (N // D)) // D
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,252:
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">import times
 
for year in 2008..2121:
if getDayOfWeek(25, mDec, year) == dSun:
stdout.write year, ' '
echo ""</langsyntaxhighlight>
 
{{out}}
Line 3,264:
=={{header|Oberon-2}}==
{{works with|oo2c version 2}}
<langsyntaxhighlight lang="oberon2">
MODULE DayOfWeek;
IMPORT NPCT:Dates, Out;
Line 3,278:
END
END DayOfWeek.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,300:
</pre>
{{works with|AOS}}
<syntaxhighlight lang="oberon2">
<lang Oberon2>
MODULE DaysOfWeek; (** AUTHOR ""; PURPOSE ""; *)
 
Line 3,320:
 
END DaysOfWeek.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,347:
{{works with|Cocoa}}
 
<langsyntaxhighlight lang="objc">#import <Foundation/Foundation.h>
 
int main()
Line 3,368:
}
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 3,393:
=={{header|OCaml}}==
{{trans|C}}
<langsyntaxhighlight lang="ocaml">#load "unix.cma"
open Unix
 
Line 3,412:
raise e
done
with _ -> ()</langsyntaxhighlight>
 
{{out}} of a run on a 32 bit machine
Line 3,429:
Unlike the previous example which only uses the OCaml standard library, here with the OCaml Calendar Library we can go until the year 2121:
 
<langsyntaxhighlight lang="ocaml">open CalendarLib
 
let list_make_seq first last =
Line 3,446:
Date.day_of_week (Date.make year 12 25) = Date.Sun) years in
print_endline "December 25 is a Sunday in:";
List.iter (Printf.printf "%d\n") years</langsyntaxhighlight>
 
{{out}}
Line 3,471:
=={{header|Oforth}}==
 
<langsyntaxhighlight Oforthlang="oforth">import: date
seqFrom(2008, 2121) filter(#[ 12 25 Date newDate dayOfWeek Date.SUNDAY == ]) .</langsyntaxhighlight>
{{out}}
<pre>
Line 3,480:
=={{header|ooRexx}}==
===Christmas===
<langsyntaxhighlight ooRexxlang="oorexx">date = .datetime~new(2008, 12, 25)
lastdate = .datetime~new(2121, 12, 25)
 
Line 3,492:
end
 
say "Christmas falls on Sunday in the years" resultList~toString("Line", ", ")</langsyntaxhighlight>
{{out}}
<pre>Christmas falls on Sunday in the years 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118</pre>
===Weekday===
<langsyntaxhighlight ooRexxlang="oorexx">/* REXX */
Parse Arg yyyymmdd
If arg(1)='' |,
Line 3,506:
wd=.Array~of('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')
dt=.DateTime~new(y,m,d)
say yyyymmdd 'is a' wd[dt~weekday]</langsyntaxhighlight>
{{out}}
<pre>H:\>rexx wd ?
Line 3,515:
 
=={{header|PARI/GP}}==
<langsyntaxhighlight lang="parigp">
njd(D) =
{
Line 3,526:
 
for (y = 2008, 2121, if (njd([y,12,25]) % 7 == 1, print(y)));
</syntaxhighlight>
</lang>
 
Output:
Line 3,554:
 
=={{header|Peloton}}==
<langsyntaxhighlight lang="sgml"><@ SAI>
<@ ITEFORLI3>2121|2008|
<@ LETVARCAP>Christmas Day|25-Dec-<@ SAYVALFOR>...</@></@>
Line 3,562:
</@>
</@>
</@></langsyntaxhighlight>
 
English dialect variable-length space-padded opcodes
<langsyntaxhighlight lang="html"><# suppressimplicitoutput>
<# iterate foriteration literalstring3>2121|2008|
<# let variable capture>Christmas Day|25-Dec-<# say value foriteration>...</#></#>
Line 3,574:
</#>
</#></langsyntaxhighlight>
 
{{out}}
Line 3,597:
=={{header|Perl}}==
 
<langsyntaxhighlight lang="perl">#! /usr/bin/perl -w
 
use Time::Local;
Line 3,612:
}
 
exit 0;</langsyntaxhighlight>
 
{{out}}
Line 3,627:
 
Using the DateTime module from CPAN:
<langsyntaxhighlight lang="perl">#! /usr/bin/perl -w
 
use DateTime;
Line 3,644:
}
 
exit 0;</langsyntaxhighlight>
or shorter:
<langsyntaxhighlight lang="perl">#! /usr/bin/perl -w
 
use DateTime;
Line 3,656:
}
 
exit 0;</langsyntaxhighlight>
{{out}}
<pre>
Line 3,679:
 
Alternatively in one line using grep (read from right to left):
<langsyntaxhighlight lang="perl">#! /usr/bin/perl -w
 
use DateTime;
Line 3,686:
print join " ", grep { DateTime->new(year => $_, month => 12, day => 25)->day_of_week == 7 } (2008 .. 2121);
 
0;</langsyntaxhighlight>
{{out}}
<pre>2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</pre>
Line 3,692:
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<langsyntaxhighlight Phixlang="phix">-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Day_of_the_week.exw</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{<span style="color: #0000FF;">}</span>
Line 3,701:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #0000FF;">?<span style="color: #000000;">res
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 3,709:
=={{header|PHP}}==
 
<langsyntaxhighlight lang="php"><?php
for($i=2008; $i<2121; $i++)
{
Line 3,718:
}
}
?></langsyntaxhighlight>
 
{{out}}
Line 3,742:
 
=={{header|Picat}}==
<langsyntaxhighlight Picatlang="picat">go =>
L = [Year : Year in 2008..2121, dow(Year, 12, 25) == 0],
println(L),
Line 3,755:
end,
R = (Y + Y // 4 - Y // 100 + Y // 400 + T[M] + D) mod 7.
</syntaxhighlight>
</lang>
 
{{out}}
Line 3,762:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(for (Y 2008 (>= 2121 Y) (inc Y))
(when (= "Sunday" (day (date Y 12 25)))
(printsp Y) ) )</langsyntaxhighlight>
{{out}}
<pre>2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</pre>
 
=={{header|Pike}}==
<langsyntaxhighlight Pikelang="pike">filter(Calendar.Year(2008)->range(Calendar.Year(2121))->years()->month(12)->day(25), lambda(object day){ return day->week_day()==7; })->year()->format_nice();</langsyntaxhighlight>
{{out}}
<pre>
Line 3,794:
 
=={{header|PL/I}}==
<syntaxhighlight lang="pl/i">
<lang PL/I>
declare i picture '9999';
do i = 2008 to 2121;
Line 3,800:
put skip list ('Christmas day ' || i || ' is a Sunday');
end;
</syntaxhighlight>
</lang>
 
==={{header|PL/I-80}}===
<langsyntaxhighlight PLlang="pl/Ii">/* Test of PL/I-80 routine to determine day of the week */
 
sunday_christmas:
Line 3,845:
 
end sunday_christmas;
</syntaxhighlight>
</lang>
{{out}}
<pre>Christmas will fall on Sunday in these years:
Line 3,868:
 
=={{header|PowerShell}}==
<langsyntaxhighlight lang="powershell">2008..2121 | Where-Object { (Get-Date $_-12-25).DayOfWeek -eq "Sunday" }</langsyntaxhighlight>
 
===Find Christmas holiday for any day and/or year===
<syntaxhighlight lang="powershell">
<lang PowerShell>
function Get-ChristmasHoliday
{
Line 3,906:
}
}
</syntaxhighlight>
</lang>
Satisfy the task requirement:
<syntaxhighlight lang="powershell">
<lang PowerShell>
2008..2121 | Get-ChristmasHoliday | where DayOfWeek -match Su
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,934:
</pre>
Get days off for a random year:
<syntaxhighlight lang="powershell">
<lang PowerShell>
Get-ChristmasHoliday -Year (2008..2121 | Get-Random)
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,944:
</pre>
Get days off for the current year using the '''Year''' property returned by <code>Get-Date</code>:
<syntaxhighlight lang="powershell">
<lang PowerShell>
(Get-Date | Get-ChristmasHoliday).DaysOff
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,956:
</pre>
Get days off for the current year as <code>[DateTime]</code> objects:
<syntaxhighlight lang="powershell">
<lang PowerShell>
(Get-Date | Get-ChristmasHoliday).DaysOff | Get-Date
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,970:
=={{header|Prolog}}==
Works with SWI-Prolog;
<langsyntaxhighlight Prologlang="prolog">main() :-
christmas_days_falling_on_sunday(2011, 2121, SundayList),
writeln(SundayList).
Line 3,982:
day_of_the_week(Date, DayOfTheWeek),
DayOfTheWeek == 7.
</syntaxhighlight>
</lang>
{{out}}
<pre>?- main.
Line 3,990:
=={{header|PureBasic}}==
PureBasic's internal Date() is limited between 1970-01-01 00:00:00 and 2038-01-19 03:14:07
<langsyntaxhighlight PureBasiclang="purebasic">For i=2008 To 2037
If DayOfWeek(Date(i,12,25,0,0,0))=0
PrintN(Str(i))
EndIf
Next</langsyntaxhighlight>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">from calendar import weekday, SUNDAY
 
[year for year in range(2008, 2122) if weekday(year, 12, 25) == SUNDAY]</langsyntaxhighlight>
{{out}}
<pre>[2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]</pre>
Line 4,008:
Or, in terms of datetime:
{{Works with|Python|3.7}}
<langsyntaxhighlight lang="python">'''Days of the week'''
 
from datetime import date
Line 4,078:
# MAIN --
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>Years between 2008 and 2121 with 25 Dec on a Sunday:
Line 4,106:
Using Tomohiko Sakamoto's algorithm.
 
<langsyntaxhighlight Quackerylang="quackery"> [ over 3 < if [ 1 - ]
dup 4 / over +
over 100 / -
Line 4,119:
2121 1+ 2008 - times
[ 25 12 i^ 2008 + dayofweek
0 = if [ i^ 2008 + echo sp ] ] </langsyntaxhighlight>
 
{{out}}
Line 4,127:
 
=={{header|R}}==
<langsyntaxhighlight Rlang="r">years <- 2008:2121
xmas <- as.POSIXlt(paste0(years, '/12/25'))
years[xmas$wday==0]
Line 4,147:
 
# Under MS Windows, write instead
Sys.setlocale("LC_ALL", "English")</langsyntaxhighlight>
 
=={{header|Racket}}==
 
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket
 
Line 4,161:
(for ([y (in-range 2008 2121)] #:when (xmas-on-sunday? y))
(displayln y))
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
Line 4,170:
As Perl 5, except <code>DateTime</code> is built-in, so you don't need to download a module of that name:
 
<syntaxhighlight lang="raku" perl6line>say join ' ', grep { Date.new($_, 12, 25).day-of-week == 7 }, 2008 .. 2121;</langsyntaxhighlight>
 
=={{header|REBOL}}==
<langsyntaxhighlight REBOLlang="rebol">REBOL [
Title: "Yuletide Holiday"
URL: http://rosettacode.org/wiki/Yuletide_Holiday
Line 4,181:
d: to-date reduce [y 12 25]
if 7 = d/weekday [prin [y ""]]
]</langsyntaxhighlight>
 
{{out}}
Line 4,187:
 
=={{header|Red}}==
<langsyntaxhighlight Redlang="red">Red []
repeat yy 114 [
d: to-date reduce [25 12 (2007 + yy )]
Line 4,202:
d/year: d/year + 1
]
</syntaxhighlight>
</lang>
{{out}}<pre>25-Dec-2011
25-Dec-2016
Line 4,244:
===using DATE weekday===
The extended &nbsp; DATE &nbsp; parameters (arguments 2 and 3) are only supported by the newer REXX interpreters.
<langsyntaxhighlight lang="rexx"> do year=2008 to 2121
if date('w', year"1225", 's') == 'Sunday' then say year
end /*year*/</langsyntaxhighlight>
{{out|output}}
<pre>
Line 4,270:
===using DATE base===
The extended DATE parameters (arguments 2 and 3) are only supported by the newer REXX interpreters.
<langsyntaxhighlight lang="rexx"> do year=2008 to 2121
if date('b', year"1225", 's') // 7 == 6 then say year
end /*year*/</langsyntaxhighlight>
{{out|output|text=&nbsp; is identical to the 1<sup>st</sup> REXX version.}} <br><br>
 
Line 4,283:
 
Language note: &nbsp; the DATE &nbsp; built-in function always returns the day-of-week in English, no matter what the native language is in effect.
<langsyntaxhighlight lang="rexx">/*REXX program displays in which years 12/25 (December 25th) falls on a Sunday. */
parse arg start finish . /*get the START and FINISH years. */
if start=='' | start=="," then start=2008 /*Not specified? Then use the default.*/
Line 4,298:
say 'December 25th,' y "falls on a Sunday."
end /*y*/
/*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 4,322:
===old school DOW ===
This &nbsp; DOW &nbsp; (day-of-week) &nbsp; version will work with any version of a REXX interpreter.
<langsyntaxhighlight lang="rexx">/*REXX program (old school) displays in which years 12/25 (Dec. 25th) falls on a Sunday.*/
parse arg start finish . /*get the START and FINISH years. */
if start=='' | start=="," then start=2008 /*Not specified? Then use the default.*/
Line 4,334:
dow: procedure; parse arg m,d,y; if m<3 then do; m= m+12; y= y-1; end
yL= left(y, 2); yr= right(y, 2); w= (d + (m+1)*26%10 +yr +yr%4 +yL%4 +5*yL) //7
if w==0 then w= 7; return w /*Sunday=1, Monday=2, ··· Saturday=7*/</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 4,357:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
for n = 2008 to 2121
if n < 2100 leap = n - 1900 else leap = n - 1904 ok
Line 4,363:
if m = 4 see "25 Dec " + n + nl ok
next
</syntaxhighlight>
</lang>
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">require 'date'
 
(2008..2121).each {|year| puts "25 Dec #{year}" if Date.new(year, 12, 25).sunday? }</langsyntaxhighlight>
{{out}}
<pre>
Line 4,391:
 
Or using the Time class
<langsyntaxhighlight lang="ruby">(2008..2121).each {|year| puts "25 Dec #{year}" if Time.local(year, 12, 25).sunday?}</langsyntaxhighlight>
{{output}}
<pre>
Line 4,416:
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang="runbasic">for year = 2008 to 2121
if val(date$("12-25-";year)) mod 7 = 5 then print "For ";year;"xmas is Sunday"
next year</langsyntaxhighlight><pre>
For 2011 xmas is Sunday
For 2016 xmas is Sunday
Line 4,439:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">extern crate chrono;
 
use chrono::prelude::*;
Line 4,446:
let years = (2008..2121).filter(|&y| Local.ymd(y, 12, 25).weekday() == Weekday::Sun).collect::<Vec<i32>>();
println!("Years = {:?}", years);
}</langsyntaxhighlight>
 
Output:
Line 4,453:
 
=={{header|S-BASIC}}==
<syntaxhighlight lang="basic">
<lang BASIC>
$constant SUNDAY = 0
 
Line 4,487:
next year
end
</syntaxhighlight>
</lang>
{{out}}
<pre>Christmas will fall on a Sunday in
Line 4,509:
 
=={{header|SAS}}==
<langsyntaxhighlight lang="sas">data _null_;
do y=2008 to 2121;
a=mdy(12,25,y);
Line 4,517:
 
/* 2011 2016 2022 2033 2039 2044 2050 2061 2067
2072 2078 2089 2095 2101 2107 2112 2118 */</langsyntaxhighlight>
 
=={{header|Scala}}==
{{libheader|Scala}}
===JDK (discouraged) ===
<langsyntaxhighlight lang="scala">import java.util.{ Calendar, GregorianCalendar }
import Calendar.{ DAY_OF_WEEK, DECEMBER, SUNDAY }
 
Line 4,539:
s"${yuletide.length} Years between ${years.head} and ${years.last}" +
" including where Christmas is observed on Sunday:\n", ", ", "."))
}</langsyntaxhighlight>
===JDK >= 8 (recommended)===
====Naive programming====
<langsyntaxhighlight lang="scala">import java.time.{ DayOfWeek, LocalDate }
 
object DayOfTheWeek1 extends App {
Line 4,554:
s"${yuletide.count(p => true)} Years between ${years.head} and ${years.last}" +
" including where Christmas is observed on Sunday:\n", ", ", "."))
}</langsyntaxhighlight>
====Idiomatic programming====
<langsyntaxhighlight lang="scala">import java.time.{ DayOfWeek, LocalDate }
 
object DayOfTheWeek1 extends App {
Line 4,571:
s"${yuletide.length} Years between ${years.head} and ${years.last}" +
" including where Christmas is observed on Sunday:\n", ", ", "."))
}</langsyntaxhighlight>
====Tail recursion====
<langsyntaxhighlight lang="scala">import java.time.{ DayOfWeek, LocalDate }
import scala.annotation.tailrec
 
Line 4,597:
s"${yuletide.length} Years between ${years.head} and ${years.last}" +
" including where Christmas is observed on Sunday:\n", ", ", "."))
}</langsyntaxhighlight>
{{out | Output of all solutions }}
<pre>Years between 2008 and 2121 including when Christmas is observed on Sunday:
Line 4,603:
 
=={{header|Scheme}}==
<langsyntaxhighlight lang="scheme">(define (day-of-week year month day)
(if (< month 3)
(begin (set! month (+ month 12)) (set! year (- year 1))))
Line 4,621:
 
(task)
; (2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118)</langsyntaxhighlight>
 
=={{header|Seed7}}==
Line 4,627:
the function [http://seed7.sourceforge.net/libraries/time.htm#dayOfWeek%28in_time%29 dayOfWeek],
which returns 1 for monday, 2 for tuesday, and so on up to 7 for sunday.
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "time.s7i";
 
Line 4,639:
end if;
end for;
end func;</langsyntaxhighlight>
{{out}}
<pre>
Line 4,662:
 
=={{header|SenseTalk}}==
<langsyntaxhighlight lang="sensetalk">// In what years between 2008 and 2121 will the 25th of December be a Sunday?
 
repeat with year = 2008 to 2121
Line 4,669:
put "Christmas in " & year & " falls on a Sunday"
end if
end repeat</langsyntaxhighlight>
{{out}}
<pre>
Line 4,693:
=={{header|Sidef}}==
{{trans|Perl}}
<langsyntaxhighlight lang="ruby">require('Time::Local')
 
for year in (2008 .. 2121) {
Line 4,701:
say "25 Dec #{year} is Sunday"
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 4,724:
=={{header|Simula}}==
{{trans|Sinclair ZX81 BASIC}}
<langsyntaxhighlight lang="simula">BEGIN
INTEGER M,D,Y;
M := 12;
Line 4,740:
END;
END;
END.</langsyntaxhighlight>
{{out}}
<pre>2011
Line 4,761:
 
=={{header|Smalltalk}}==
<langsyntaxhighlight lang="smalltalk">2008 to: 2121 do: [ :year | |date|
date := Date newDay: 25 monthIndex: 12 year: year.
date dayName = #Sunday
ifTrue: [ date displayNl ]
]</langsyntaxhighlight>
 
{{out}}
Line 4,790:
SQL has good support for date functions; care must be taken with NLS settings (globalization support), in the code below the date format language is passed in as an argument to the relevant function. (Or, see a variation that does not depend on language settings, after the output shown below.)
 
<langsyntaxhighlight lang="sql">select extract(year from dt) as year_with_xmas_on_sunday
from (
select add_months(date '2008-12-25', 12 * (level - 1)) as dt
Line 4,798:
where to_char(dt, 'Dy', 'nls_date_language=English') = 'Sun'
order by 1
;</langsyntaxhighlight>
 
 
Line 4,827:
Alternatively, the WHERE clause can be written in a way that avoids the complication of language settings. The (overloaded) TRUNC function, as applied to dates, takes a second argument indicating "to what" we must truncate. One option is 'iw' for "ISO week"; this truncates to the most recent Monday (the beginning of the ISO standard week, which is Monday through Sunday by definition). Like so (replace in the query above):
 
<langsyntaxhighlight lang="sql">where dt - trunc(dt, 'iw') = 6</langsyntaxhighlight>
 
=={{header|Standard ML}}==
<langsyntaxhighlight lang="sml">(* Call: yearsOfSundayXmas(2008, 2121) *)
fun yearsOfSundayXmas(fromYear, toYear) =
if fromYear>toYear then
Line 4,848:
else
yearsOfSundayXmas(fromYear+1, toYear)
end;</langsyntaxhighlight>
 
{{out}}
Line 4,873:
 
The [https://www.stata.com/help.cgi?dow() <code>dow()</code>] function returns the day of week, where sunday is zero and saturday is 6.
<langsyntaxhighlight lang="stata">clear
sca n=2121-2008+1
set obs `=n'
Line 4,899:
| 2112 |
| 2118 |
+------+</langsyntaxhighlight>
 
=== Mata ===
 
<langsyntaxhighlight lang="mata">year=2008::2121
select(year,dow(mdy(12,25,year)):==0)</langsyntaxhighlight>
 
=={{header|Suneido}}==
<langsyntaxhighlight Suneidolang="suneido">year = 2008
while (year <= 2121)
{
Line 4,913:
Print(year)
++year
}</langsyntaxhighlight>
{{out}}
<pre>2011
Line 4,934:
 
=={{header|Swift}}==
<langsyntaxhighlight Swiftlang="swift">import Cocoa
 
var year=2008
Line 4,949:
}
year++
}</langsyntaxhighlight>
{{out}}
<pre>2011
Line 4,971:
=={{header|Tcl}}==
{{works with|Tcl|8.5}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
 
for {set y 2008} {$y <= 2121} {incr y} {
Line 4,977:
puts "xmas $y is a sunday"
}
}</langsyntaxhighlight>
{{out}}
<pre>xmas 2011 is a sunday
Line 4,999:
=={{header|TI-83 BASIC}}==
'''Works with''' TI-84+/SE only
<langsyntaxhighlight lang="ti83b">
:For(A,2008,2121
:If dayofWk(A,12,25)=1
:Disp A
:End
</syntaxhighlight>
</lang>
{{out}}
<pre>2011
Line 5,026:
 
=={{header|TUSCRIPT}}==
<langsyntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
PRINT "25th of December will be a Sunday in the following years: "
Line 5,033:
IF (dayofweek==7) PRINT year
ENDLOOP
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 5,058:
== {{header|TypeScript}} ==
{{trans|Minimal BASIC}}
<langsyntaxhighlight lang="javascript">
// Find years with Sunday Christmas
var f = 2008;
Line 5,069:
}
process.stdout.write("\n");
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 5,083:
 
{{works with|bash}}
<langsyntaxhighlight lang="bash">#! /bin/bash
 
for (( i=2008; i<=2121; ++i ))
Line 5,090:
done |grep Sun
 
exit 0</langsyntaxhighlight>
 
The first lines of output (from a GNU/Linux system with 32bit time_t, date version 6.9) are
 
<langsyntaxhighlight lang="bash">Sun Dec 25 00:00:00 CET 2011
Sun Dec 25 00:00:00 CET 2016
Sun Dec 25 00:00:00 CET 2022
Sun Dec 25 00:00:00 CET 2033
date: invalid date `2038-12-25'</langsyntaxhighlight>
 
I.e., starting from year 2038, the <tt>date</tt> command (which uses the glibc library, at least on GNU systems), is not able to recognise the date as a valid one!
Line 5,104:
''Different machine/OS version (64 bit time_t):''
This is the same command run on RedHat Linux.
<langsyntaxhighlight lang="bash">bash-3.00$ date --version
date (coreutils) 5.2.1
Written by David MacKenzie.
Line 5,131:
Sun Dec 25 00:00:00 GMT 2112
Sun Dec 25 00:00:00 GMT 2118
bash-3.00$</langsyntaxhighlight>
 
===With GNU date and GNU seq ({{header|UnixPipes}})===
Like the previous solution, this solution uses date -d, which seems to be a [[GNU]] extension. Output is same as previous solution.
 
<langsyntaxhighlight lang="bash">seq 2008 2121 | xargs -IYEAR -n 1 date +%c -d 'Dec 25 YEAR' | grep Sun</langsyntaxhighlight>
 
===With Unix cal===
Line 5,154:
 
{{works with|Bourne Shell}}
<langsyntaxhighlight lang="bash">y=2008
while test $y -lt 2122; do
cal 12 $y | tail +3 | cut -c1-2 | grep -Fq 25 && echo 25 Dec $y
y=`expr $y + 1`
done</langsyntaxhighlight>
 
Running this script with [[OpenBSD]], the output is identical to the C# program. OpenBSD ''cal'' accepts any year from 1 to 9999, so 2008 to 2122 is well within range.
 
===With zsh===
<langsyntaxhighlight lang="bash">zmodload zsh/datetime
for (( year = 2010; year <= 2121; year++ ));
if [[ $(strftime '%A' $(strftime -r '%F' $year-12-25)) == Sunday ]] print $year</langsyntaxhighlight>
 
If the system has 32-bit time, this script will malfunction for years >= 2038; it will print no year from 2038 to 2121 (unless today is Sunday, then it prints every year from 2038 to 2121). This happens because ''strftime -r '%F' $year-12-25'' yields -1 for an out-of-range date, and ''strftime '%A' -1'' yields name of today.
Line 5,182:
date with the weekday included. The output is then filtered for Sundays.
 
<langsyntaxhighlight Ursalalang="ursala">#import std
#import nat
#import stt
Line 5,190:
#show+
 
sunday_years = ~&zS sep` * =]'Sun'*~ christmases</langsyntaxhighlight>
{{out}}
<pre>2011
Line 5,211:
 
=={{header|VBA}}==
<langsyntaxhighlight lang="vb">Option Explicit
 
Sub MainDayOfTheWeek()
Line 5,223:
Next
XmasSunday = Mid(temp, 2)
End Function</langsyntaxhighlight>
 
{{Out}}
Line 5,229:
 
=={{header|VBScript}}==
<langsyntaxhighlight lang="vb">For year = 2008 To 2121
If Weekday(DateSerial(year, 12, 25)) = 1 Then
WScript.Echo year
End If
Next</langsyntaxhighlight>
 
{{Out}}
Line 5,257:
 
=={{header|Vedit macro language}}==
<langsyntaxhighlight lang="vedit">Buf_Switch(Buf_Free)
for (#3 = 2008; #3 < 2122; #3++) {
Reg_Set(10, "12/25/")
Line 5,264:
Num_Ins(#3, NOCR)
}
}</langsyntaxhighlight>
 
{{out}}
Line 5,272:
 
=={{header|Visual Objects}}==
<langsyntaxhighlight lang="visualfoxpro">
local i as dword
Line 5,280:
endif
next i
</syntaxhighlight>
</lang>
 
{{out}}
Line 5,289:
=={{header|Vlang}}==
Updated for Vlang version 0.2.2
<langsyntaxhighlight lang="go">import time
 
fn main() {
Line 5,298:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 5,324:
{{Trans|ALGOL W}}...which is {{Trans|Fortran}}
VTL-2 does not have operator precedence - all expressions are evaluated left-to-right, except for expressions nested in parenthesis, hence the expression at line 1090 differs from that in the Algol W sample.
<langsyntaxhighlight VTL2lang="vtl2">1000 #=2000
1010 R=!
1020 N=M
Line 5,345:
2080 Y=Y+1
2090 #=Y<2121*2040
2100 ?=""</langsyntaxhighlight>
{{out}}
<pre>
Line 5,352:
 
=={{header|Wortel}}==
<langsyntaxhighlight lang="wortel">!-&y = 0 `.getDay. @new Date[y 11 25] @range[2008 2121]</langsyntaxhighlight>
Returns: <pre>[2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118]</pre>
 
=={{header|Wren}}==
{{libheader|Wren-date}}
<langsyntaxhighlight lang="ecmascript">import "/date" for Date
 
System.print("Years between 2008 and 2121 when 25th December falls on Sunday:")
for (year in 2008..2121) {
if (Date.new(year, 12, 25).dayOfWeek == 7) System.print(year)
}</langsyntaxhighlight>
 
{{out}}
Line 5,391:
the Gregorian calendar, from 1583 onward. It's based on Zeller's Congruence.
 
<langsyntaxhighlight XPL0lang="xpl0">include c:\cxpl\codes; \intrinsic 'code' declarations
 
func WeekDay(Year, Month, Day); \Return day of week (0=Sat 1=Sun..6=Fri)
Line 5,404:
if WeekDay(Year, 12, 25) = 1 then \25th of December is a Sunday
[IntOut(0, Year); CrLf(0)];
]</langsyntaxhighlight>
 
{{out}}
Line 5,429:
=={{header|Yabasic}}==
{{trans|FreeBASIC}}
<langsyntaxhighlight Yabasiclang="yabasic">sub wd(m, d, y)
If m < 3 Then // If m = 1 Or m = 2 Then
m = m + 12
Line 5,443:
Print "Dec 25 ", yr
EndIf
Next</langsyntaxhighlight>
 
=={{header|zkl}}==
ISO dates, monday is 1, sunday is 7
<langsyntaxhighlight lang="zkl">var [const] D=Time.Date;
foreach y in ([2008..2121]){
if (D.Sunday==D.weekDay(y,12,25)) println(y)
}</langsyntaxhighlight>
Or, in a more functional manner:
<langsyntaxhighlight lang="zkl">var [const] D=Time.Date;
[2008..2121].filter(fcn(y){ D.Sunday==D.weekDay(y,12,25) }).println()</langsyntaxhighlight>
{{out}}
<pre>
Line 5,476:
 
=={{header|zonnon}}==
<langsyntaxhighlight lang="zonnon">
module Main;
(*Access to Mono System package *)
Line 5,488:
System.Console.WriteLine(now.DayOfWeek);
end Main.
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 5,496:
=={{header|ZX Spectrum Basic}}==
{{trans|BASIC}}
<langsyntaxhighlight lang="zxbasic">10 CLS
20 FOR y=2008 TO 2121
30 LET year=y: LET m=12: LET d=25: GO SUB 1000
Line 5,506:
1020 LET wd=FN m(year+INT (year/4)-INT (year/100)+INT (year/400)+d+INT ((153*m+8)/5),7)
1030 RETURN
1100 DEF FN m(a,b)=a-INT (a/b)*b</langsyntaxhighlight>
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.