Holidays related to Easter: Difference between revisions

Content added Content deleted
(→‎{{header|BASH}}: Typo and output)
m (syntax highlighting fixup automation)
Line 64: Line 64:
For maximum compatibility, this program uses only the basic instruction set (S/360)
For maximum compatibility, this program uses only the basic instruction set (S/360)
and two ASSIST macros (XDECO, XPRNT) to keep the code as short as possible.
and two ASSIST macros (XDECO, XPRNT) to keep the code as short as possible.
<lang 360asm>* Holidays related to Easter 29/05/2016
<syntaxhighlight lang="360asm">* Holidays related to Easter 29/05/2016
HOLIDAYS CSECT
HOLIDAYS CSECT
USING HOLIDAYS,R13 base register
USING HOLIDAYS,R13 base register
Line 246: Line 246:
XDEC DS CL12 temp for edit
XDEC DS CL12 temp for edit
YREGS
YREGS
END HOLIDAYS</lang>
END HOLIDAYS</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 284: Line 284:
=={{header|Ada}}==
=={{header|Ada}}==
Ada.Calendar can only handle years in the range 1901 to 2399.
Ada.Calendar can only handle years in the range 1901 to 2399.
<lang Ada>with Ada.Calendar.Arithmetic;
<syntaxhighlight lang="ada">with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Calendar.Formatting;
with Ada.Text_IO;
with Ada.Text_IO;
Line 335: Line 335:
Print_Easter (I);
Print_Easter (I);
end loop;
end loop;
end Main;</lang>
end Main;</syntaxhighlight>


output:
output:
Line 363: Line 363:
Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
-->
-->
<lang algol68>MODE YEAR = INT, MONTH = INT, WEEK = INT, DAY = INT;
<syntaxhighlight lang="algol68">MODE YEAR = INT, MONTH = INT, WEEK = INT, DAY = INT;


MODE DATE = STRUCT(
MODE DATE = STRUCT(
Line 484: Line 484:


printf (($l"Christian holidays, related to Easter, for years from 2010 to 2020 CE:"l$));
printf (($l"Christian holidays, related to Easter, for years from 2010 to 2020 CE:"l$));
FOR year FROM 2010 TO 2020 DO easter related print(year) OD</lang>
FOR year FROM 2010 TO 2020 DO easter related print(year) OD</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 522: Line 522:


=={{header|BASH}}==
=={{header|BASH}}==
<lang bash>
<syntaxhighlight lang="bash">
#! /bin/bash
#! /bin/bash
# Carter's calendar algorithm: https://web.archive.org/web/19990117015544/http://www.ast.cam.ac.uk/pubinfo/leaflets/easter/easter.html
# Carter's calendar algorithm: https://web.archive.org/web/19990117015544/http://www.ast.cam.ac.uk/pubinfo/leaflets/easter/easter.html
Line 565: Line 565:
done
done


</syntaxhighlight>
</lang>
<pre>
<pre>
2020-04-12
2020-04-12
Line 598: Line 598:
{{works with|BBC BASIC for Windows}}
{{works with|BBC BASIC for Windows}}
As discussed on the Talk page, the task is not well defined for historical dates because the change from the Julian to the Gregorian calendar happened on different dates in different regions. Therefore only dates from 1800 onwards are output, by which time most countries (particularly those likely to celebrate the Christian Easter) had adopted the Gregorian calendar.
As discussed on the Talk page, the task is not well defined for historical dates because the change from the Julian to the Gregorian calendar happened on different dates in different regions. Therefore only dates from 1800 onwards are output, by which time most countries (particularly those likely to celebrate the Christian Easter) had adopted the Gregorian calendar.
<lang bbcbasic> INSTALL @lib$+"DATELIB"
<syntaxhighlight lang="bbcbasic"> INSTALL @lib$+"DATELIB"
PRINT "Year Easter Ascension Pentecost Trinity Corpus"
PRINT "Year Easter Ascension Pentecost Trinity Corpus"
Line 624: Line 624:
e% -= ((year% MOD 7) + b% - d% + e% + 2) MOD 7
e% -= ((year% MOD 7) + b% - d% + e% + 2) MOD 7
d% = e% >>> 5
d% = e% >>> 5
= FN_mjd(e% - d% * 31, d% + 3, year%)</lang>
= FN_mjd(e% - d% * 31, d% + 3, year%)</syntaxhighlight>
'''Output:'''
'''Output:'''
<pre>
<pre>
Line 654: Line 654:
This program switches calendar from Julian to Gregorian during October 1582. Its algorithm takes from [http://www.merlyn.demon.co.uk/zel-1886.htm ''Kalendar-Formeln'' by Zeller (1886)].
This program switches calendar from Julian to Gregorian during October 1582. Its algorithm takes from [http://www.merlyn.demon.co.uk/zel-1886.htm ''Kalendar-Formeln'' by Zeller (1886)].


<lang bc>scale = 0
<syntaxhighlight lang="bc">scale = 0


/* Format d days after March 21. Assumes March, April, May or June. */
/* Format d days after March 21. Assumes March, April, May or June. */
Line 713: Line 713:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
z = easter(2100)
quit</lang>
quit</syntaxhighlight>


{{out}}
{{out}}
Line 751: Line 751:
This program switches calendar from Julian to Gregorian during March 1924. Pentecost and Trinity Sunday are the same day; [[wp:All Saints' Sunday|All Saints' Sunday]] is the next Sunday.
This program switches calendar from Julian to Gregorian during March 1924. Pentecost and Trinity Sunday are the same day; [[wp:All Saints' Sunday|All Saints' Sunday]] is the next Sunday.


<lang bc>scale = 0
<syntaxhighlight lang="bc">scale = 0


/* Format d days after March 21. Assumes March, April, May or June. */
/* Format d days after March 21. Assumes March, April, May or June. */
Line 805: Line 805:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
z = easter(2100)
quit</lang>
quit</syntaxhighlight>


{{out}}
{{out}}
Line 844: Line 844:


First two rows initialise the set of years to be processed; second two output the header; the main algorithm starts on row six.
First two rows initialise the set of years to be processed; second two output the header; the main algorithm starts on row six.
<lang Befunge>037*>1- : 9`#v_2*4+>1-:3`#v_v
<syntaxhighlight lang="befunge">037*>1- : 9`#v_2*4+>1-:3`#v_v
^\+*"(2":< ^\*"d":< >$ v
^\+*"(2":< ^\*"d":< >$ v
v"Pentcst"9"Trinity"9"Corpus"+550<
v"Pentcst"9"Trinity"9"Corpus"+550<
Line 856: Line 856:
>"'"\>:9\>:156*+`!#v_156*+-\3v>$$^
>"'"\>:9\>:156*+`!#v_156*+-\3v>$$^
+9,^ ^\+3\-*65_v#`*65:\+ <^_
+9,^ ^\+3\-*65_v#`*65:\+ <^_
*84,g4+1,g4:+1,g4:\< >:#\!#.^#,</lang>
*84,g4+1,g4:+1,g4:\< >:#\!#.^#,</syntaxhighlight>
{{out}}
{{out}}
<pre>Year Easter Ascensn Pentcst Trinity Corpus
<pre>Year Easter Ascensn Pentcst Trinity Corpus
Line 892: Line 892:
{{trans|ALGOL 68|Note: This specimen retains the original [[Holidays related to Easter#ALGOL 68|ALGOL 68]] coding style -
{{trans|ALGOL 68|Note: This specimen retains the original [[Holidays related to Easter#ALGOL 68|ALGOL 68]] coding style -
[http://rosettacode.org/mw/index.php?title=Holidays_related_to_Easter&diff=85840&oldid=85839 diff].}}
[http://rosettacode.org/mw/index.php?title=Holidays_related_to_Easter&diff=85840&oldid=85839 diff].}}
<lang C>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>


typedef int year_t, month_t, week_t, day_t;
typedef int year_t, month_t, week_t, day_t;
Line 1,013: Line 1,013:
for(year=2010; year<=2020; year++){ easter_related_print(year); }
for(year=2010; year<=2020; year++){ easter_related_print(year); }
return 0;
return 0;
}</lang>
}</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 1,053: Line 1,053:
{{works with|C sharp|3.0}}
{{works with|C sharp|3.0}}


<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;
using System.Collections;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Specialized;
Line 1,110: Line 1,110:
}
}
}
}
</syntaxhighlight>
</lang>


Output:
Output:
Line 1,149: Line 1,149:


=={{header|COBOL}}==
=={{header|COBOL}}==
<lang cobol>
<syntaxhighlight lang="cobol">
identification division.
identification division.
program-id. Easter.
program-id. Easter.
Line 1,273: Line 1,273:
move holiday-day to edt-day
move holiday-day to edt-day
.
.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
Implemented the task for 1700 and greater years because COBOL is a Business language and their routines only works after Day zero that is equals to 00:00:00 31 December 1600
Implemented the task for 1700 and greater years because COBOL is a Business language and their routines only works after Day zero that is equals to 00:00:00 31 December 1600
Line 1,298: Line 1,298:


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
<lang lisp>; Easter sunday. Result is a list '(month day)
<syntaxhighlight lang="lisp">; Easter sunday. Result is a list '(month day)
;
;
; See:
; See:
Line 1,316: Line 1,316:
(setq m (floor (+ a (* 11 h) (* 22 l)) 451))
(setq m (floor (+ a (* 11 h) (* 22 l)) 451))
(multiple-value-setq (n p) (floor (+ h l (- 114 (* 7 m))) 31))
(multiple-value-setq (n p) (floor (+ h l (- 114 (* 7 m))) 31))
(list n (1+ p))))</lang>
(list n (1+ p))))</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
{{trans|C sharp}}
{{trans|C sharp}}
<lang d>import std.stdio, std.datetime;
<syntaxhighlight lang="d">import std.stdio, std.datetime;


void printEasterRelatedHolidays(in int year) {
void printEasterRelatedHolidays(in int year) {
Line 1,372: Line 1,372:
foreach (immutable y; 2010 .. 2021)
foreach (immutable y; 2010 .. 2021)
printEasterRelatedHolidays(y);
printEasterRelatedHolidays(y);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Line 1,409: Line 1,409:
{{libheader| System.SysUtils}}
{{libheader| System.SysUtils}}
{{Trans|D}}
{{Trans|D}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Holidays_related_to_Easter;
program Holidays_related_to_Easter;


Line 1,491: Line 1,491:
printEasterRelatedHolidays(y);
printEasterRelatedHolidays(y);
readln;
readln;
end.</lang>
end.</syntaxhighlight>


=={{header|Elixir}}==
=={{header|Elixir}}==
{{trans|Ruby}}
{{trans|Ruby}}
<lang elixir>defmodule Holiday do
<syntaxhighlight lang="elixir">defmodule Holiday do
@offsets [ Easter: 0, Ascension: 39, Pentecost: 49, Trinity: 56, Corpus: 60 ]
@offsets [ Easter: 0, Ascension: 39, Pentecost: 49, Trinity: 56, Corpus: 60 ]
@mon { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
@mon { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
Line 1,535: Line 1,535:
end
end


Holiday.task</lang>
Holiday.task</syntaxhighlight>


{{out}}
{{out}}
Line 1,574: Line 1,574:
=={{header|Erlang}}==
=={{header|Erlang}}==
{{trans|Elixir}}
{{trans|Elixir}}
<lang erlang>-module(holidays).
<syntaxhighlight lang="erlang">-module(holidays).
-export([task/0]).
-export([task/0]).


Line 1,636: Line 1,636:
task(Year, Max, Step) ->
task(Year, Max, Step) ->
holidays(Year),
holidays(Year),
task(Year+Step, Max, Step).</lang>
task(Year+Step, Max, Step).</syntaxhighlight>


{{out}}
{{out}}
Line 1,679: Line 1,679:
Factor already has an <code>easter</code> word in its <code>calendar</code> vocabulary, but is has been re-implemented here as it seems in the spirit of the task.
Factor already has an <code>easter</code> word in its <code>calendar</code> vocabulary, but is has been re-implemented here as it seems in the spirit of the task.
{{works with|Factor|0.99 2019-10-06}}
{{works with|Factor|0.99 2019-10-06}}
<lang factor>USING: calendar formatting io kernel locals math math.ranges
<syntaxhighlight lang="factor">USING: calendar formatting io kernel locals math math.ranges
sequences ;
sequences ;


Line 1,712: Line 1,712:


400 2100 100 holidays nl
400 2100 100 holidays nl
2010 2020 1 holidays</lang>
2010 2020 1 holidays</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,750: Line 1,750:


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth>
<syntaxhighlight lang="forth">
variable year
variable year


Line 1,800: Line 1,800:
LOOP
LOOP
;
;
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,837: Line 1,837:


=={{header|Fortran}}==
=={{header|Fortran}}==
<lang fortran> subroutine easter(year,month,day)
<syntaxhighlight lang="fortran"> subroutine easter(year,month,day)
c Easter sunday
c Easter sunday
c
c
Line 1,865: Line 1,865:
month=n/31
month=n/31
day=mod(n,31)+1
day=mod(n,31)+1
end</lang>
end</syntaxhighlight>


=={{header|Fōrmulæ}}==
=={{header|Fōrmulæ}}==
Line 1,878: Line 1,878:
{{trans|ALGOL 68}}
{{trans|ALGOL 68}}
This solution takes the ALGOL 68 as a reference solution, using its math for calculating the holidays, and reproducing its output.
This solution takes the ALGOL 68 as a reference solution, using its math for calculating the holidays, and reproducing its output.
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 1,947: Line 1,947:
newEasterRelated(y).print()
newEasterRelated(y).print()
}
}
}</lang>
}</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 1,990: Line 1,990:
Aside from the already noted issues and inconsistencies with extending these calculations back centuries, the calculation of the correct and proper date of Easter has historically been responsible for massive conflict in Western history including excommunications, near wars, and contributing to the splitting of the Catholic Church. For more see [http://mangsbatpage.433rd.com/2008/03/calculating-easter.html Calculating Easter @ Mang's Bat Page].
Aside from the already noted issues and inconsistencies with extending these calculations back centuries, the calculation of the correct and proper date of Easter has historically been responsible for massive conflict in Western history including excommunications, near wars, and contributing to the splitting of the Catholic Church. For more see [http://mangsbatpage.433rd.com/2008/03/calculating-easter.html Calculating Easter @ Mang's Bat Page].


<lang Icon>link printf
<syntaxhighlight lang="icon">link printf


procedure main()
procedure main()
Line 2,054: Line 2,054:
}
}
return dr
return dr
end</lang>
end</syntaxhighlight>


Output:<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Output:<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Line 2,105: Line 2,105:
This code is based on the above rationale, and http://www.merlyn.demon.co.uk/estr-bcp.htm and the wikipedia pages referenced in the task description:
This code is based on the above rationale, and http://www.merlyn.demon.co.uk/estr-bcp.htm and the wikipedia pages referenced in the task description:


<lang j>jed=:3 :0
<syntaxhighlight lang="j">jed=:3 :0
pfm=. 21 + 30 | _4 + 19 * 1 + 19|y
pfm=. 21 + 30 | _4 + 19 * 1 + 19|y
sn=. 6 - 7 | 4 + <.@*&1.25 y
sn=. 6 - 7 | 4 + <.@*&1.25 y
dys=. 1 40 50 50 +/~sn (] + 7 | 4 + -) pfm
dys=. 1 40 50 50 +/~sn (] + 7 | 4 + -) pfm
y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys
y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys
)</lang>
)</syntaxhighlight>


Required example:
Required example:


<lang j> jed (400 + 100* i.17),(2010 + i.11),2100</lang>
<syntaxhighlight lang="j"> jed (400 + 100* i.17),(2010 + i.11),2100</syntaxhighlight>
output:
output:
<pre style="height: 24ex; overflow: scroll"> 400 4 1
<pre style="height: 24ex; overflow: scroll"> 400 4 1
Line 2,267: Line 2,267:
Nevertheless, here is an implementation which reproduces those numbers, based on the same resource I used for the Julian easters:
Nevertheless, here is an implementation which reproduces those numbers, based on the same resource I used for the Julian easters:


<lang j>ged=:3 :0
<syntaxhighlight lang="j">ged=:3 :0
ce =. <. y%100
ce =. <. y%100
GN =. 1 + 19 | y
GN =. 1 + 19 | y
Line 2,277: Line 2,277:
dys=. 0 39 49 56 60 +/~ DM + 1 + 7 | 60+SN-DM
dys=. 0 39 49 56 60 +/~ DM + 1 + 7 | 60+SN-DM
y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys
y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys
)</lang>
)</syntaxhighlight>


And here is the required example (and note that I am including the same Corpus Christi feast date here that others are using, because that makes sense with recent Gregorian dates even though it is a nonsense value for earlier dates):
And here is the required example (and note that I am including the same Corpus Christi feast date here that others are using, because that makes sense with recent Gregorian dates even though it is a nonsense value for earlier dates):


<lang j> ged (400 + 100* i.17),(2010 + i.11),2100</lang>
<syntaxhighlight lang="j"> ged (400 + 100* i.17),(2010 + i.11),2100</syntaxhighlight>
output (in each block of dates, they are, in order Easter, Ascension Thursday, Pentecost, Trinity Sunday, and Corpus Christi feast):
output (in each block of dates, they are, in order Easter, Ascension Thursday, Pentecost, Trinity Sunday, and Corpus Christi feast):
<pre style="height: 24ex; overflow: scroll"> 400 4 2
<pre style="height: 24ex; overflow: scroll"> 400 4 2
Line 2,459: Line 2,459:
=={{header|Java}}==
=={{header|Java}}==
Translation of C Sharp via D
Translation of C Sharp via D
<lang java>import java.text.DateFormatSymbols;
<syntaxhighlight lang="java">import java.text.DateFormatSymbols;
import java.util.*;
import java.util.*;


Line 2,517: Line 2,517:
System.out.println();
System.out.println();
}
}
}</lang>
}</syntaxhighlight>


Output:
Output:
Line 2,556: Line 2,556:
=={{header|JavaScript}}==
=={{header|JavaScript}}==
(English version courtesy of google translate below)
(English version courtesy of google translate below)
<lang javascript>const Пасха = год => {
<syntaxhighlight lang="javascript">const Пасха = год => {
let дата = (год % 19 * 19 + 15) % 30;
let дата = (год % 19 * 19 + 15) % 30;
дата += (год % 4 * 2 + год % 7 * 4 + 6 * дата + 6) % 7;
дата += (год % 4 * 2 + год % 7 * 4 + 6 * дата + 6) % 7;
Line 2,574: Line 2,574:
);
);
}
}
</syntaxhighlight>
</lang>


Output:
Output:
Line 2,608: Line 2,608:
=== English version ===
=== English version ===
(same output)
(same output)
<lang javascript>const Easter = year => {
<syntaxhighlight lang="javascript">const Easter = year => {
let date = (year % 19 * 19 + 15) % 30;
let date = (year % 19 * 19 + 15) % 30;
date += (year % 4 * 2 + year % 7 * 4 + 6 * date + 6) % 7;
date += (year % 4 * 2 + year % 7 * 4 + 6 * date + 6) % 7;
Line 2,625: Line 2,625:
}).join("; ") + ".<br />"
}).join("; ") + ".<br />"
);
);
}</lang>
}</syntaxhighlight>


=== Universal algorithm ===
=== Universal algorithm ===
<lang javascript>function getEasterDate(year = new Date().getFullYear(), church = 1, calendar = year < 1918 ? 1 : 2) {
<syntaxhighlight lang="javascript">function getEasterDate(year = new Date().getFullYear(), church = 1, calendar = year < 1918 ? 1 : 2) {
/* year: a number of the year (from 325 CE);
/* year: a number of the year (from 325 CE);
church: an algorithm of the computus,
church: an algorithm of the computus,
Line 2,682: Line 2,682:


for (let year = 400; year <= 2100; year += year < 2000 ? 100 : year >= 2021 ? 80 : year < 2010 ? 10 : 1)
for (let year = 400; year <= 2100; year += year < 2000 ? 100 : year >= 2021 ? 80 : year < 2010 ? 10 : 1)
document.write(getHolidaysDates(year, 1) + " <br />");</lang>
document.write(getHolidaysDates(year, 1) + " <br />");</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia># v0.6
<syntaxhighlight lang="julia"># v0.6


using Dates
using Dates
Line 2,727: Line 2,727:
for yr in 2010:2020
for yr in 2010:2020
println(holiday2str(yr))
println(holiday2str(yr))
end</lang>
end</syntaxhighlight>


{{out}}
{{out}}
Line 2,766: Line 2,766:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|C#}}
{{trans|C#}}
<lang scala>// version 1.1.2
<syntaxhighlight lang="scala">// version 1.1.2


import java.util.Calendar
import java.util.Calendar
Line 2,823: Line 2,823:
println()
println()
for (year in 2010..2020) outputHolidays(year)
for (year in 2010..2020) outputHolidays(year)
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,864: Line 2,864:
=={{header|Lua}}==
=={{header|Lua}}==
The function 'easter' is a Lua translation of a C function by Claus Tøndering. This script relies heavily on the 'time' library, available from scilua.org. Dates before 1582 are not supported.
The function 'easter' is a Lua translation of a C function by Claus Tøndering. This script relies heavily on the 'time' library, available from scilua.org. Dates before 1582 are not supported.
<lang Lua>local Time = require("time")
<syntaxhighlight lang="lua">local Time = require("time")


function div (x, y) return math.floor(x / y) end
function div (x, y) return math.floor(x / y) end
Line 2,901: Line 2,901:
print("Year\tEaster\tAscen.\tPent.\tTrinity\tCorpus")
print("Year\tEaster\tAscen.\tPent.\tTrinity\tCorpus")
for year = 1600, 2100, 100 do show(year, holidays(year)) end
for year = 1600, 2100, 100 do show(year, holidays(year)) end
for year = 2010, 2020 do show(year, holidays(year)) end</lang>
for year = 2010, 2020 do show(year, holidays(year)) end</syntaxhighlight>
Output:
Output:
<pre>Year Easter Ascen. Pent. Trinity Corpus
<pre>Year Easter Ascen. Pent. Trinity Corpus
Line 2,923: Line 2,923:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>Needs["Calendar`"];DateFormat[x_]:=DateString[x,{"DayNameShort"," ","DayShort"," ","MonthName"}]
<syntaxhighlight lang="mathematica">Needs["Calendar`"];DateFormat[x_]:=DateString[x,{"DayNameShort"," ","DayShort"," ","MonthName"}]
Map[StringJoin[ToString[#]," Easter: ",DateFormat[EasterSunday[#]],
Map[StringJoin[ToString[#]," Easter: ",DateFormat[EasterSunday[#]],
", Ascension: ",DateFormat[DaysPlus[EasterSunday[#],39]],
", Ascension: ",DateFormat[DaysPlus[EasterSunday[#],39]],
Line 2,960: Line 2,960:
2018 Easter: Sun 1 April, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus: Thu 31 May,
2018 Easter: Sun 1 April, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus: Thu 31 May,
2019 Easter: Sun 21 April, Ascension: Thu 30 May, Pentecost: Sun 9 June, Trinity: Sun 16 June, Corpus: Thu 20 June,
2019 Easter: Sun 21 April, Ascension: Thu 30 May, Pentecost: Sun 9 June, Trinity: Sun 16 June, Corpus: Thu 20 June,
2020 Easter: Sun 12 April, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 June, Corpus: Thu 11 June}</lang>
2020 Easter: Sun 12 April, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 June, Corpus: Thu 11 June}</syntaxhighlight>


=={{header|Maxima}}==
=={{header|Maxima}}==
<lang maxima>/* Easter sunday. Result is a list [month, day]
<syntaxhighlight lang="maxima">/* Easter sunday. Result is a list [month, day]


See:
See:
Line 2,973: Line 2,973:
f:quotient(b+8,25),g:quotient(b-f+1,3),h:remainder(19*a+b-d-g+15,30),
f:quotient(b+8,25),g:quotient(b-f+1,3),h:remainder(19*a+b-d-g+15,30),
[i,k]:divide(c,4),l:remainder(32+2*e+2*i-h-k,7),m:quotient(a+11*h+22*l,451),
[i,k]:divide(c,4),l:remainder(32+2*e+2*i-h-k,7),m:quotient(a+11*h+22*l,451),
[n,p]:divide(h+l-7*m+114,31),[n,p+1])$</lang>
[n,p]:divide(h+l-7*m+114,31),[n,p+1])$</syntaxhighlight>


=={{header|МК-61/52}}==
=={{header|МК-61/52}}==
<lang>П2 1 9 ПП 86 П3 ИП2 4 ПП 86
<syntaxhighlight lang="text">П2 1 9 ПП 86 П3 ИП2 4 ПП 86
П4 ИП2 7 ПП 86 П5 1 9 ИП3 *
П4 ИП2 7 ПП 86 П5 1 9 ИП3 *
1 5 + 3 0 ПП 86 П6 2 ИП4
1 5 + 3 0 ПП 86 П6 2 ИП4
Line 2,985: Line 2,985:
- x>=0 76 П3 КИП4 ИП3 3 0 - x>=0
- x>=0 76 П3 КИП4 ИП3 3 0 - x>=0
83 П3 КИП4 ИП3 ИП4 С/П П0 <-> П1 <->
83 П3 КИП4 ИП3 ИП4 С/П П0 <-> П1 <->
/ [x] ИП0 * ИП1 - /-/ В/О</lang>
/ [x] ИП0 * ИП1 - /-/ В/О</syntaxhighlight>


Calculated, of course, the Orthodox Easter. Enter the number of the year, the result of: the day in the register Y, a month in the register X.
Calculated, of course, the Orthodox Easter. Enter the number of the year, the result of: the day in the register Y, a month in the register X.
Line 2,991: Line 2,991:
For the subsequent calculation of Ascension and Pentecost (Trinity Day):
For the subsequent calculation of Ascension and Pentecost (Trinity Day):


<lang>П0 <-> П1 <-> - 1 3 + П1 3
<syntaxhighlight lang="text">П0 <-> П1 <-> - 1 3 + П1 3
1 - x>=0 19 П1 ИП0 1 + П0 ИП0
1 - x>=0 19 П1 ИП0 1 + П0 ИП0
1 + П0 ИП1 ИП0 С/П ИП1 1 0 +
1 + П0 ИП1 ИП0 С/П ИП1 1 0 +
П1 3 1 - x>=0 41 П1 ИП0 1 +
П1 3 1 - x>=0 41 П1 ИП0 1 +
П0 ИП1 ИП0 С/П</lang>
П0 ИП1 ИП0 С/П</syntaxhighlight>


''Example'': Easter in 2014 is 20.04; Ascension is 29.05; Pentecost is 08.06.
''Example'': Easter in 2014 is 20.04; Ascension is 29.05; Pentecost is 08.06.
Line 3,003: Line 3,003:
=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang Nim>import strformat, strutils, times
<syntaxhighlight lang="nim">import strformat, strutils, times


const HolidayOffsets = {"Easter": 0, "Ascension": 39, "Pentecost": 49,
const HolidayOffsets = {"Easter": 0, "Ascension": 39, "Pentecost": 49,
Line 3,043: Line 3,043:
for year in countup(400, 2100, 100): outputHolidays(year)
for year in countup(400, 2100, 100): outputHolidays(year)
echo ""
echo ""
for year in 2010..2020: outputHolidays(year)</lang>
for year in 2010..2020: outputHolidays(year)</syntaxhighlight>


{{out}}
{{out}}
Line 3,083: Line 3,083:
Code handles Gregorian / Julian holidays and dates correctly. Calendar reform was 1582-10-04.
Code handles Gregorian / Julian holidays and dates correctly. Calendar reform was 1582-10-04.


<lang parigp>/*
<syntaxhighlight lang="parigp">/*
* Normalized Julian Day Number from date (base 1899-12-30 00:00:00)
* Normalized Julian Day Number from date (base 1899-12-30 00:00:00)
* D = Vec [year, month, day]
* D = Vec [year, month, day]
Line 3,163: Line 3,163:
print("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:");
print("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:");
for (y = 2010, 2020, holiday(y));
for (y = 2010, 2020, holiday(y));
</syntaxhighlight>
</lang>


Output:
Output:
Line 3,206: Line 3,206:




<lang perl>#!/usr/bin/perl
<syntaxhighlight lang="perl">#!/usr/bin/perl


use strict; use warnings;
use strict; use warnings;
Line 3,270: Line 3,270:


cholidays($_) for(2010..2020);
cholidays($_) for(2010..2020);
</syntaxhighlight>
</lang>


Output:
Output:
Line 3,310: Line 3,310:
The Phix timedate routines make no attempt to support pre-1752 dates, but the algorithm seems to work.<br>
The Phix timedate routines make no attempt to support pre-1752 dates, but the algorithm seems to work.<br>
(Note: that pre-1752 part got itself broken on 0.8.1, but is back working on the as-yet-unreleased 0.8.2)
(Note: that pre-1752 part got itself broken on 0.8.1, but is back working on the as-yet-unreleased 0.8.2)
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Easter.exw</span>
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Easter.exw</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">easter</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">easter</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
Line 3,367: Line 3,367:
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 3,404: Line 3,404:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(load "@lib/cal.l") # For 'easter' function
<syntaxhighlight lang="picolisp">(load "@lib/cal.l") # For 'easter' function


(de dayMon (Dat)
(de dayMon (Dat)
Line 3,418: Line 3,418:
", Pentecost: " (dayMon (+ E 49))
", Pentecost: " (dayMon (+ E 49))
", Trinity: " (dayMon (+ E 56))
", Trinity: " (dayMon (+ E 56))
", Corpus: " (dayMon (+ E 60)) ) ) )</lang>
", Corpus: " (dayMon (+ E 60)) ) ) )</syntaxhighlight>
Output:
Output:
<pre> 400 Easter: Sun 2 Apr, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus: Thu 1 Jun
<pre> 400 Easter: Sun 2 Apr, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus: Thu 1 Jun
Line 3,451: Line 3,451:


=={{header|PL/I}}==
=={{header|PL/I}}==
<lang>(subscriptrange, size, fofl):
<syntaxhighlight lang="text">(subscriptrange, size, fofl):
Easter: procedure options (main);
Easter: procedure options (main);
declare months(12) character (9) varying static initial (
declare months(12) character (9) varying static initial (
Line 3,492: Line 3,492:
end Easter_Sunday;
end Easter_Sunday;


end Easter;</lang>
end Easter;</syntaxhighlight>
Results:
Results:
<pre>
<pre>
Line 3,519: Line 3,519:


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
function Get-Easter
function Get-Easter
{
{
Line 3,591: Line 3,591:
}
}
}
}
</syntaxhighlight>
</lang>
<syntaxhighlight lang="powershell">
<lang PowerShell>
$years = for ($i = 400; $i -le 2100; $i+=100) {$i}
$years = for ($i = 400; $i -le 2100; $i+=100) {$i}
$years0400to2100 = $years | Get-Easter
$years0400to2100 = $years | Get-Easter
Line 3,601: Line 3,601:
Write-Host "Christian holidays, related to Easter, for years from 2010 to 2020 AD:"
Write-Host "Christian holidays, related to Easter, for years from 2010 to 2020 AD:"
$years2010to2020 | Format-Table
$years2010to2020 | Format-Table
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 3,646: Line 3,646:


=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>DataSection
<syntaxhighlight lang="purebasic">DataSection
C_DAYS:
C_DAYS:
Data.i 0,39,49,56,60
Data.i 0,39,49,56,60
Line 3,720: Line 3,720:
PrintN("")
PrintN("")
For i=2010 To 2020 : PutTab(i) : PrintN(r$) : Next
For i=2010 To 2020 : PutTab(i) : PrintN(r$) : Next
Input()</lang>
Input()</syntaxhighlight>
{{out}}
{{out}}
<pre>Year Easter Ascension Pentecost Trinity C/Christi
<pre>Year Easter Ascension Pentecost Trinity C/Christi
Line 3,762: Line 3,762:
Unfortunately, at present Python doesn't support date formatting for any dates before 1900. So while it is trivial to get the date for easter, it takes a bit more work to format the date.
Unfortunately, at present Python doesn't support date formatting for any dates before 1900. So while it is trivial to get the date for easter, it takes a bit more work to format the date.


<lang python>from dateutil.easter import *
<syntaxhighlight lang="python">from dateutil.easter import *
import datetime, calendar
import datetime, calendar


Line 3,797: Line 3,797:
print_holidays(get_holiday_values(year))
print_holidays(get_holiday_values(year))


</syntaxhighlight>
</lang>


Output:
Output:
Line 3,837: Line 3,837:
=={{header|R}}==
=={{header|R}}==


<syntaxhighlight lang="r">
<lang R>
library(tidyverse)
library(tidyverse)
library(lubridate)
library(lubridate)
Line 3,874: Line 3,874:
`Corpus Christi` = Trinity + 4,
`Corpus Christi` = Trinity + 4,
across(.fns = pretty_date))
across(.fns = pretty_date))
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 3,918: Line 3,918:
(formerly Perl 6)
(formerly Perl 6)
{{trans|Perl}}
{{trans|Perl}}
<lang perl6>my @abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >;
<syntaxhighlight lang="raku" line>my @abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >;
my @holidays =
my @holidays =
Line 3,957: Line 3,957:
for flat (400,500 ... 2000), (2010 ... 2020), 2100 -> $year {
for flat (400,500 ... 2000), (2010 ... 2020), 2100 -> $year {
cholidays($year);
cholidays($year);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> 400: Easter: 02 Apr, Ascension: 11 May, Pentecost: 21 May, Trinity: 28 May, Corpus: 01 Jun
<pre> 400: Easter: 02 Apr, Ascension: 11 May, Pentecost: 21 May, Trinity: 28 May, Corpus: 01 Jun
Line 3,990: Line 3,990:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/* REXX **********************************************************************************
<syntaxhighlight lang="rexx">/* REXX **********************************************************************************
* Test frame for computing Christian (Roman Catholic) holidays, related to Easter
* Test frame for computing Christian (Roman Catholic) holidays, related to Easter
* 16.04.2013 Walter Pachl
* 16.04.2013 Walter Pachl
Line 4,063: Line 4,063:
month=n%31
month=n%31
day=n//31+1
day=n//31+1
Return year month day</lang>
Return year month day</syntaxhighlight>
Output:
Output:
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2200 CE:
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2200 CE:
Line 4,112: Line 4,112:
{{works with|Ruby|1.8.7}}
{{works with|Ruby|1.8.7}}


<lang ruby>require 'date'
<syntaxhighlight lang="ruby">require 'date'


def easter_date(year)
def easter_date(year)
Line 4,150: Line 4,150:
400.step(2100, 100).each {|year| emit_dates year}
400.step(2100, 100).each {|year| emit_dates year}
puts
puts
(2010 .. 2020).each {|year| emit_dates year}</lang>
(2010 .. 2020).each {|year| emit_dates year}</syntaxhighlight>


outputs
outputs
Line 4,188: Line 4,188:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>
<syntaxhighlight lang="rust">
use std::ops::Add;
use std::ops::Add;


Line 4,234: Line 4,234:
}
}
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 4,270: Line 4,270:
=={{header|Scala}}==
=={{header|Scala}}==
{{trans|bc}}
{{trans|bc}}
<lang scala>import java.util._
<syntaxhighlight lang="scala">import java.util._
import scala.swing._
import scala.swing._


Line 4,330: Line 4,330:
size = new java.awt.Dimension(600, 400)
size = new java.awt.Dimension(600, 400)
visible = true
visible = true
}</lang>
}</syntaxhighlight>


=={{header|Scheme}}==
=={{header|Scheme}}==
<lang scheme>; Easter sunday. Result is a list '(month day)
<syntaxhighlight lang="scheme">; Easter sunday. Result is a list '(month day)
;
;
; See:
; See:
Line 4,353: Line 4,353:
(m (quotient (+ a (* 11 h) (* 22 l)) 451))
(m (quotient (+ a (* 11 h) (* 22 l)) 451))
(n (+ h l (- 114 (* 7 m)))))
(n (+ h l (- 114 (* 7 m)))))
(list (quotient n 31) (+ 1 (remainder n 31)))))</lang>
(list (quotient n 31) (+ 1 (remainder n 31)))))</syntaxhighlight>


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "time.s7i";
include "time.s7i";
include "duration.s7i";
include "duration.s7i";
Line 4,442: Line 4,442:
writeHolidays(year);
writeHolidays(year);
end for;
end for;
end func;</lang>
end func;</syntaxhighlight>


Original source of the function easterDate, which uses the Gauss formula: [http://seed7.sourceforge.net/algorith/date.htm#easterDate]
Original source of the function easterDate, which uses the Gauss formula: [http://seed7.sourceforge.net/algorith/date.htm#easterDate]
Line 4,484: Line 4,484:
=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Raku}}
{{trans|Raku}}
<lang ruby>require('Date::Calc')
<syntaxhighlight lang="ruby">require('Date::Calc')


var abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >
var abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >
Line 4,527: Line 4,527:
for year in (400..2100 `by` 100, 2010..2020) {
for year in (400..2100 `by` 100, 2010..2020) {
cholidays(year)
cholidays(year)
}</lang>
}</syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
<lang tcl>package require Tcl 8.5; # Advanced date handling engine
<syntaxhighlight lang="tcl">package require Tcl 8.5; # Advanced date handling engine


# Easter computation code from http://www.assa.org.au/edm.html
# Easter computation code from http://www.assa.org.au/edm.html
Line 4,597: Line 4,597:
for {set year 2010} {$year <= 2020} {incr year} {
for {set year 2010} {$year <= 2020} {incr year} {
puts [DateInfo $year]
puts [DateInfo $year]
}</lang>
}</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 4,636: Line 4,636:
=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
For dates before October 15, 1582 the Julian Calendar is taken as basis.
For dates before October 15, 1582 the Julian Calendar is taken as basis.
<lang tuscript>
<syntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
$$ MODE TUSCRIPT
SET years=*
SET years=*
Line 4,655: Line 4,655:
ENDLOOP
ENDLOOP
ENDLOOP
ENDLOOP
</syntaxhighlight>
</lang>
Output:
Output:
<pre style='height:30ex;overflow:scroll'>
<pre style='height:30ex;overflow:scroll'>
Line 4,811: Line 4,811:


=={{header|VBA}}==
=={{header|VBA}}==
{{trans|Phix}}<lang vb>Public dates As Variant
{{trans|Phix}}<syntaxhighlight lang="vb">Public dates As Variant
Private Function easter(year_ As Integer) As Date
Private Function easter(year_ As Integer) As Date
'-- from https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
'-- from https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
Line 4,861: Line 4,861:
show year_
show year_
Next year_
Next year_
End Sub</lang>{{out}}
End Sub</syntaxhighlight>{{out}}
<pre> Easter Ascension Pentecost Trinity Corpus
<pre> Easter Ascension Pentecost Trinity Corpus
400 zo 02 apr do 11 mei zo 21 mei zo 28 mei do 01 jun
400 zo 02 apr do 11 mei zo 21 mei zo 28 mei do 01 jun
Line 4,899: Line 4,899:
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
{{libheader|Wren-trait}}
{{libheader|Wren-trait}}
<lang ecmascript>import "/date" for Date
<syntaxhighlight lang="ecmascript">import "/date" for Date
import "/fmt" for Fmt
import "/fmt" for Fmt
import "/trait" for Stepped
import "/trait" for Stepped
Line 4,950: Line 4,950:
for (year in Stepped.new(400..2100, 100)) outputHolidays.call(year)
for (year in Stepped.new(400..2100, 100)) outputHolidays.call(year)
System.print()
System.print()
for (year in 2010..2020) outputHolidays.call(year)</lang>
for (year in 2010..2020) outputHolidays.call(year)</syntaxhighlight>


{{out}}
{{out}}