Holidays related to Easter: Difference between revisions

m
(→‎{{header|BASH}}: Adding BASH)
m (→‎{{header|Wren}}: Minor tidy)
 
(17 intermediate revisions by 11 users not shown)
Line 64:
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.
<langsyntaxhighlight lang="360asm">* Holidays related to Easter 29/05/2016
HOLIDAYS CSECT
USING HOLIDAYS,R13 base register
Line 246:
XDEC DS CL12 temp for edit
YREGS
END HOLIDAYS</langsyntaxhighlight>
{{out}}
<pre>
Line 284:
=={{header|Ada}}==
Ada.Calendar can only handle years in the range 1901 to 2399.
<langsyntaxhighlight Adalang="ada">with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Text_IO;
Line 335:
Print_Easter (I);
end loop;
end Main;</langsyntaxhighlight>
 
output:
Line 363:
Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
-->
<langsyntaxhighlight lang="algol68">MODE YEAR = INT, MONTH = INT, WEEK = INT, DAY = INT;
 
MODE DATE = STRUCT(
Line 484:
 
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</langsyntaxhighlight>
Output:
<pre>
Line 520:
2020 Easter: Sun 12 Apr, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 Jun, Corpus: Thu 11 Jun
</pre>
 
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">holidayOffsets: #[
"Easter": 0
"Ascension": 39
"Pentecost": 49
"Trinity": 56
"C/Christi": 60
]
 
easterDate: function [year][
a: year % 19
b: year / 100
c: year % 100
d: b / 4
e: b % 4
f: (b + 8) / 25
g: (1 + b - f) / 3
h: (((b - d) - g) + 15 + 19 * a) % 30
i: c / 4
k: c % 4
l: (32 + (2 * e) + ((2 * i) - h) - k) % 7
m: (a + (11 * h) + (22 * l)) / 451
n: h + (l - (7 * m)) + 114
month: n / 31
day: (n % 31) + 1
return to :date .format:"d-M-YYYY" ~"|day|-|month|-|year|"
]
 
outputHolidays: function [year][
edate: easterDate year
 
prints pad to :string year 4
prints " "
 
loop holidayOffsets [holiday, offset][
newDate: after.days:offset edate
s: to :string .format:"dd MMM" newDate
prints pad.center s size holiday
prints " "
]
print ""
]
 
print "Year Easter Ascension Pentecost Trinity C/Christi"
print " CE Sunday Thursday Sunday Sunday Thursday "
print "---- ------ --------- ---------- ------- ---------"
 
loop range.step:100 400 2100 => outputHolidays
print ""
loop 2010..2020 => outputHolidays</syntaxhighlight>
 
{{out}}
 
<pre>Year Easter Ascension Pentecost Trinity C/Christi
CE Sunday Thursday Sunday Sunday Thursday
---- ------ --------- ---------- ------- ---------
400 02 Apr 11 May 21 May 28 May 01 Jun
500 04 Apr 13 May 23 May 30 May 03 Jun
600 13 Apr 22 May 01 Jun 08 Jun 12 Jun
700 15 Apr 24 May 03 Jun 10 Jun 14 Jun
800 23 Apr 01 Jun 11 Jun 18 Jun 22 Jun
900 28 Mar 06 May 16 May 23 May 27 May
1000 30 Mar 08 May 18 May 25 May 29 May
1100 08 Apr 17 May 27 May 03 Jun 07 Jun
1200 09 Apr 18 May 28 May 04 Jun 08 Jun
1300 18 Apr 27 May 06 Jun 13 Jun 17 Jun
1400 20 Apr 29 May 08 Jun 15 Jun 19 Jun
1500 01 Apr 10 May 20 May 27 May 31 May
1600 02 Apr 11 May 21 May 28 May 01 Jun
1700 11 Apr 20 May 30 May 06 Jun 10 Jun
1800 13 Apr 22 May 01 Jun 08 Jun 12 Jun
1900 15 Apr 24 May 03 Jun 10 Jun 14 Jun
2000 23 Apr 01 Jun 11 Jun 18 Jun 22 Jun
2100 28 Mar 06 May 16 May 23 May 27 May
 
2010 04 Apr 13 May 23 May 30 May 03 Jun
2011 24 Apr 02 Jun 12 Jun 19 Jun 23 Jun
2012 08 Apr 17 May 27 May 03 Jun 07 Jun
2013 31 Mar 09 May 19 May 26 May 30 May
2014 20 Apr 29 May 08 Jun 15 Jun 19 Jun
2015 05 Apr 14 May 24 May 31 May 04 Jun
2016 27 Mar 05 May 15 May 22 May 26 May
2017 16 Apr 25 May 04 Jun 11 Jun 15 Jun
2018 01 Apr 10 May 20 May 27 May 31 May
2019 21 Apr 30 May 09 Jun 16 Jun 20 Jun
2020 12 Apr 21 May 31 May 07 Jun 11 Jun</pre>
 
=={{header|BASH}}==
<langsyntaxhighlight lang="bash">
#! /bin/bash
# Carter's calendar algorithm: https://web.archive.org/web/19990117015544/http://www.ast.cam.ac.uk/pubinfo/leaflets/easter/easter.html
# vim: ts=4 :
set -e
# Calendar algorithm source: https://www.rmg.co.uk/stories/topics/when-easter
 
 
easter() {
y(( year=$1 ))
 
if [[ $year -gt 2099 ]]
if [[ year -gt 2099 ]]
then
echo "Error: year This algorithm does not work after 2099."
exit 1
fi
 
(( day = 225 - 11 * (year % 19) ))
 
while [[(( $day -gt> 50 ]]))
do
(( day -= 30 ))
done
 
if [(( $day -gt> 48 ]))
then
(( --day ))
Line 553 ⟶ 640:
}
 
for year in {1998..20992100}
do
(( day=$( easter $year ) ))
if [(( $day -gt< 3132 ]))
then
printf "%d-%02d-%02d\n" $year 3 $day
else
(( day -= 31 ))
printf "%d-%02d-%02d\n" $year 4 $day
else
printf "%d-%02d-%02d\n" $year 3 $day
fi
done
 
</syntaxhighlight>
</lang>
<pre>
2020-04-12
2021-04-04
2022-04-17
2023-04-09
2024-03-31
2025-04-20
2026-04-05
2027-03-28
2028-04-16
2029-04-01
2030-04-21
2031-04-13
..
2087-04-20
2088-04-11
2089-04-03
2090-04-16
2091-04-08
2092-03-30
2093-04-12
2094-04-04
2095-04-24
2096-04-15
2097-03-31
2098-04-20
2099-04-12
</pre>
 
=={{header|BBC BASIC}}==
{{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.
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$+"DATELIB"
PRINT "Year Easter Ascension Pentecost Trinity Corpus"
Line 596 ⟶ 711:
e% -= ((year% MOD 7) + b% - d% + e% + 2) MOD 7
d% = e% >>> 5
= FN_mjd(e% - d% * 31, d% + 3, year%)</langsyntaxhighlight>
'''Output:'''
<pre>
Line 626 ⟶ 741:
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)].
 
<langsyntaxhighlight lang="bc">scale = 0
 
/* Format d days after March 21. Assumes March, April, May or June. */
Line 685 ⟶ 800:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
quit</langsyntaxhighlight>
 
{{out}}
Line 723 ⟶ 838:
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.
 
<langsyntaxhighlight lang="bc">scale = 0
 
/* Format d days after March 21. Assumes March, April, May or June. */
Line 777 ⟶ 892:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
quit</langsyntaxhighlight>
 
{{out}}
Line 816 ⟶ 931:
 
First two rows initialise the set of years to be processed; second two output the header; the main algorithm starts on row six.
<langsyntaxhighlight Befungelang="befunge">037*>1- : 9`#v_2*4+>1-:3`#v_v
^\+*"(2":< ^\*"d":< >$ v
v"Pentcst"9"Trinity"9"Corpus"+550<
Line 828 ⟶ 943:
>"'"\>:9\>:156*+`!#v_156*+-\3v>$$^
+9,^ ^\+3\-*65_v#`*65:\+ <^_
*84,g4+1,g4:+1,g4:\< >:#\!#.^#,</langsyntaxhighlight>
{{out}}
<pre>Year Easter Ascensn Pentcst Trinity Corpus
Line 864 ⟶ 979:
{{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].}}
<langsyntaxhighlight Clang="c">#include <stdio.h>
 
typedef int year_t, month_t, week_t, day_t;
Line 985 ⟶ 1,100:
for(year=2010; year<=2020; year++){ easter_related_print(year); }
return 0;
}</langsyntaxhighlight>
Output:
<pre>
Line 1,025 ⟶ 1,140:
{{works with|C sharp|3.0}}
 
<langsyntaxhighlight lang="csharp">using System;
using System.Collections;
using System.Collections.Specialized;
Line 1,082 ⟶ 1,197:
}
}
</syntaxhighlight>
</lang>
 
Output:
Line 1,118 ⟶ 1,233:
2019 Easter: Sun 21 Apr, Ascension: Thu 30 May, Pentecost: Sun 9 Jun, Trinity: Sun 16 Jun, Corpus: Thu 20 Jun
2020 Easter: Sun 12 Apr, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 Jun, Corpus: Thu 11 Jun
</pre>
 
=={{header|C++}}==
<syntaxhighlight lang="c++">
#include <chrono>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>
 
std::chrono::year_month_day date_of_easter(const int32_t& year) {
const int32_t a = year % 19;
const int32_t b = year / 100;
const int32_t c = year % 100;
const int32_t d = b / 4;
const int32_t e = b % 4;
const int32_t f = ( b + 8 ) / 25;
const int32_t g = ( b - f + 1 ) / 3;
const int32_t h = ( 19 * a + b - d - g + 15 ) % 30;
const int32_t i = c / 4;
const int32_t k = c % 4;
const int32_t l = ( 32 + 2 * e + 2 * i - h - k ) % 7;
const int32_t m = ( a + 11 * h + 22 * l ) / 451;
const int32_t n = h + l - 7 * m + 114;
const unsigned int month = n / 31;
const unsigned int day = ( n % 31 ) + 1;
 
return { std::chrono::year{year}, std::chrono::month{month}, std::chrono::day{day} };
}
 
void display(const int32_t& year, const std::vector<int32_t>& holiday_offsets) {
std::chrono::year_month_day easter = date_of_easter(year);
 
std::cout << std::setw(4) << year;
for ( const int32_t& holiday_offset : holiday_offsets ) {
std::chrono::year_month_day date = std::chrono::sys_days(easter) + std::chrono::days{holiday_offset};
std::cout << std::setw(7) << date.day() << std::setw(4) << date.month();
}
std::cout << std::endl;
}
 
int main() {
const std::vector<int32_t> holiday_offsets{ 0, 39, 49, 56, 60 };
 
std::cout << "Year Easter Ascension Pentecost Trinity Corpus Christi" << std::endl;
std::cout << " CE Sunday Thursday Sunday Sunday Thursday " << std::endl;
std::cout << "---- ------ --------- --------- ------- --------------" << std::endl;
for ( int32_t year = 400; year <= 2100; year += 100 ) {
display(year, holiday_offsets);
}
std::cout << std::endl;
 
for ( int32_t year= 2010; year <= 2020; ++year ) {
display(year, holiday_offsets);
}
}
</syntaxhighlight>
{{ out }}
<pre>
Year Easter Ascension Pentecost Trinity Corpus Christi
CE Sunday Thursday Sunday Sunday Thursday
---- ------ --------- --------- ------- --------------
400 02 Apr 11 May 21 May 28 May 01 Jun
500 04 Apr 13 May 23 May 30 May 03 Jun
600 13 Apr 22 May 01 Jun 08 Jun 12 Jun
700 15 Apr 24 May 03 Jun 10 Jun 14 Jun
800 23 Apr 01 Jun 11 Jun 18 Jun 22 Jun
900 28 Mar 06 May 16 May 23 May 27 May
1000 30 Mar 08 May 18 May 25 May 29 May
1100 08 Apr 17 May 27 May 03 Jun 07 Jun
1200 09 Apr 18 May 28 May 04 Jun 08 Jun
1300 18 Apr 27 May 06 Jun 13 Jun 17 Jun
1400 20 Apr 29 May 08 Jun 15 Jun 19 Jun
1500 01 Apr 10 May 20 May 27 May 31 May
1600 02 Apr 11 May 21 May 28 May 01 Jun
1700 11 Apr 20 May 30 May 06 Jun 10 Jun
1800 13 Apr 22 May 01 Jun 08 Jun 12 Jun
1900 15 Apr 24 May 03 Jun 10 Jun 14 Jun
2000 23 Apr 01 Jun 11 Jun 18 Jun 22 Jun
2100 28 Mar 06 May 16 May 23 May 27 May
 
2010 04 Apr 13 May 23 May 30 May 03 Jun
2011 24 Apr 02 Jun 12 Jun 19 Jun 23 Jun
2012 08 Apr 17 May 27 May 03 Jun 07 Jun
2013 31 Mar 09 May 19 May 26 May 30 May
2014 20 Apr 29 May 08 Jun 15 Jun 19 Jun
2015 05 Apr 14 May 24 May 31 May 04 Jun
2016 27 Mar 05 May 15 May 22 May 26 May
2017 16 Apr 25 May 04 Jun 11 Jun 15 Jun
2018 01 Apr 10 May 20 May 27 May 31 May
2019 21 Apr 30 May 09 Jun 16 Jun 20 Jun
2020 12 Apr 21 May 31 May 07 Jun 11 Jun
</pre>
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol">
identification division.
program-id. Easter.
Line 1,245 ⟶ 1,452:
move holiday-day to edt-day
.
</syntaxhighlight>
</lang>
{{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
Line 1,270 ⟶ 1,477:
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">; Easter sunday. Result is a list '(month day)
;
; See:
Line 1,288 ⟶ 1,495:
(setq m (floor (+ a (* 11 h) (* 22 l)) 451))
(multiple-value-setq (n p) (floor (+ h l (- 114 (* 7 m))) 31))
(list n (1+ p))))</langsyntaxhighlight>
 
=={{header|D}}==
{{trans|C sharp}}
<langsyntaxhighlight lang="d">import std.stdio, std.datetime;
 
void printEasterRelatedHolidays(in int year) {
Line 1,344 ⟶ 1,551:
foreach (immutable y; 2010 .. 2021)
printEasterRelatedHolidays(y);
}</langsyntaxhighlight>
{{out}}
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Line 1,381 ⟶ 1,588:
{{libheader| System.SysUtils}}
{{Trans|D}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Holidays_related_to_Easter;
 
Line 1,463 ⟶ 1,670:
printEasterRelatedHolidays(y);
readln;
end.</langsyntaxhighlight>
 
=={{header|Elixir}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="elixir">defmodule Holiday do
@offsets [ Easter: 0, Ascension: 39, Pentecost: 49, Trinity: 56, Corpus: 60 ]
@mon { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
Line 1,507 ⟶ 1,714:
end
 
Holiday.task</langsyntaxhighlight>
 
{{out}}
Line 1,546 ⟶ 1,753:
=={{header|Erlang}}==
{{trans|Elixir}}
<langsyntaxhighlight lang="erlang">-module(holidays).
-export([task/0]).
 
Line 1,608 ⟶ 1,815:
task(Year, Max, Step) ->
holidays(Year),
task(Year+Step, Max, Step).</langsyntaxhighlight>
 
{{out}}
Line 1,651 ⟶ 1,858:
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}}
<langsyntaxhighlight lang="factor">USING: calendar formatting io kernel locals math math.ranges
sequences ;
 
Line 1,684 ⟶ 1,891:
 
400 2100 100 holidays nl
2010 2020 1 holidays</langsyntaxhighlight>
{{out}}
<pre>
Line 1,722 ⟶ 1,929:
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">
variable year
 
Line 1,772 ⟶ 1,979:
LOOP
;
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,809 ⟶ 2,016:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran"> subroutine easter(year,month,day)
c Easter sunday
c
Line 1,837 ⟶ 2,044:
month=n/31
day=mod(n,31)+1
end</langsyntaxhighlight>
 
=={{header|FreeBASIC}}==
{{libheader|datetime}}
{{libheader|string}}
<syntaxhighlight lang="vb">#include "datetime.bi"
#include "string.bi"
 
Dim Shared As Integer anno, mes, dia
 
Type mytype
f As String*9
d As Short
End Type
Dim Shared fechas(1 To 5) As mytype => {("Easter ",0),_
("Ascension",39),("Pentecost",49),("Trinity ",56),("Corpus ",60)}
 
Function Pascua(anno As Short) As Double
Dim As Short a, b, c, d, e
Dim As Short f, g, h, i, k
Dim As Short l, m, n
a = anno Mod 19
b = anno \ 100
c = anno Mod 100
d = b \ 4
e = b Mod 4
f = (b + 8) \ 25
g = (b - f + 1) \ 3
h = (19 * a + b - d - g + 15) Mod 30
i = c \ 4
k = c Mod 4
l = (32 + 2 * e + 2 * i - h - k) Mod 7
m = (a + 11 * h + 22 * l) \ 451
n = h + l - 7 * m + 114
Dim As Short mes = n \ 31
Dim As Short dia = n Mod 31 + 1
Return Dateserial(anno, mes, dia)
End Function
 
Sub Mostar(anno As Short)
Dim As Double e = Pascua(anno)
Print Using (" #### "); anno;
For i As Short = 1 To Ubound(fechas)
Print Format(e + fechas(i).d, "dd/mmm"); Spc(3);
Next i
Print
End Sub
 
Print " Year Easter Ascension Pentecost Trinity C/Christi"
Print " CE Sunday Thursday Sunday Sunday Thursday "
Print " ---- ------ --------- ---------- ------- ---------"
 
For anno = 400 To 2100 Step 100
Mostar(anno)
Next anno
Print
For anno = 2010 To 2020
Mostar(anno)
Next anno
 
Sleep</syntaxhighlight>
{{out}}
<pre> Year Easter Ascension Pentecost Trinity C/Christi
CE Sunday Thursday Sunday Sunday Thursday
---- ------ --------- ---------- ------- ---------
400 02/abr. 11/may. 21/may. 28/may. 01/jun.
500 04/abr. 13/may. 23/may. 30/may. 03/jun.
600 13/abr. 22/may. 01/jun. 08/jun. 12/jun.
700 15/abr. 24/may. 03/jun. 10/jun. 14/jun.
800 23/abr. 01/jun. 11/jun. 18/jun. 22/jun.
900 28/mar. 06/may. 16/may. 23/may. 27/may.
1000 30/mar. 08/may. 18/may. 25/may. 29/may.
1100 08/abr. 17/may. 27/may. 03/jun. 07/jun.
1200 09/abr. 18/may. 28/may. 04/jun. 08/jun.
1300 18/abr. 27/may. 06/jun. 13/jun. 17/jun.
1400 20/abr. 29/may. 08/jun. 15/jun. 19/jun.
1500 01/abr. 10/may. 20/may. 27/may. 31/may.
1600 02/abr. 11/may. 21/may. 28/may. 01/jun.
1700 11/abr. 20/may. 30/may. 06/jun. 10/jun.
1800 13/abr. 22/may. 01/jun. 08/jun. 12/jun.
1900 15/abr. 24/may. 03/jun. 10/jun. 14/jun.
2000 23/abr. 01/jun. 11/jun. 18/jun. 22/jun.
2100 28/mar. 06/may. 16/may. 23/may. 27/may.
 
2010 04/abr. 13/may. 23/may. 30/may. 03/jun.
2011 24/abr. 02/jun. 12/jun. 19/jun. 23/jun.
2012 08/abr. 17/may. 27/may. 03/jun. 07/jun.
2013 31/mar. 09/may. 19/may. 26/may. 30/may.
2014 20/abr. 29/may. 08/jun. 15/jun. 19/jun.
2015 05/abr. 14/may. 24/may. 31/may. 04/jun.
2016 27/mar. 05/may. 15/may. 22/may. 26/may.
2017 16/abr. 25/may. 04/jun. 11/jun. 15/jun.
2018 01/abr. 10/may. 20/may. 27/may. 31/may.
2019 21/abr. 30/may. 09/jun. 16/jun. 20/jun.
2020 12/abr. 21/may. 31/may. 07/jun. 11/jun.</pre>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?timeZone=UTC&script=examples/Holidays_related_to_Easter}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
 
This is a implementation of the [https://en.wikipedia.org/wiki/Date_of_Easter#Anonymous_Gregorian_algorithm "Meeus/Jones/Butcher" algorithm]:
 
[[File:Fōrmulæ - Holidays related to Easter 01.png]]
 
[[File:Fōrmulæ - Holidays related to Easter 02.png]]
 
'''Test cases'''
 
[[File:Fōrmulæ - Holidays related to Easter 03.png]]
 
[[File:Fōrmulæ - Holidays related to Easter 04.png]]
 
[[File:Fōrmulæ - Holidays related to Easter 05.png]]
 
[[File:Fōrmulæ - Holidays related to Easter 06.png]]
 
=={{header|FutureBasic}}==
This code outputs a complete Mac application showing the Julian Easter dates from 532 to 1582 and Gregorian Easter dates thereafter, without regard to historical niceties. The Gregorian rule has no set limits, but we went up to the year 10,000,000 (note that Gregorian Easter dates repeat every 5,700,000 years, so Easter 5702023 is on the same date as Easter 2023). Calculating other moveable feasts is trivial.
<syntaxhighlight lang=futurebasic>
 
begin enum 1
_window : _scroll : _showOff
_clmYear : _clmEaster : _lblYear : _lblEaster
_inField : _outField
end enum
 
void local fn buildInterface
window _window, @"Easter dates", ( 0, 0, 200, 200 ), 3
scrollview _scroll, ( 20, 80, 170, 91 )
textview _showOff, , _scroll
textlabel _clmYear, @"Year", ( 21, 168, 60, 22 )
textlabel _clmEaster, @"Easter", ( 92, 168, 140, 22 )
textlabel _lblYear, @"Year:", ( 40, 40, 100, 22 )
textlabel _lblEaster, @"Easter:", ( 31, 10, 100, 22 )
textlabel _outField, @"14 April", ( 87, 10, 100, 22 )
textfield _inField, , @"14250", ( 85, 42, 70, 22 )
ControlSetFormat ( _inField, @"0123456789", YES, 7, 0 )
TextSetFont( _showOff, fn FontMonospacedDigitSystemFontOfSize( 12 , 0 ) )
menu 1, , , @"File" : menu 1, 0, , @"Close", @"w"
MenuItemSetAction(1, 0, @"performClose:")
editmenu 2
WindowMakeFirstResponder( _window, _inField )
end fn
 
clear local fn easter( year as NSInteger) as CFStringRef
NSInteger goldenNumber, leapDays, century, epact
NSInteger moonAdjust, leapAdjust,fullMoon, easter
CFStringRef s = @""
goldenNumber = year mod 19 + 1 ' moon phase on 1 Jan
if year < 1583
// Algorithm by Dionysius Exiguus, 525
leapDays = 5 * year / 4 ' one leap year every four years
epact = ( 11 * goldenNumber - 4 ) mod 30 ' moon phase on 22 March
else
// Algorithm by Christoph Clavius, 1582 (see D. Knuth: CACM 1962;5:209)
century = int( year / 100 ) + 1
leapAdjust = int( ( 3 * century / 4 ) - 12 ) ' correct leap years
leapDays = int( 5 * year / 4 ) - leapAdjust - 10 ' new calculation of leap days
moonAdjust = int( ( 8 * century + 5 ) / 25 ) - 5 ' correct moon cycle
epact = ( 11 * goldenNumber + moonAdjust - leapAdjust + 20 ) mod 30 ' new calculation of moon phase
if epact < 0 then epact += 30
if ( epact = 24 or ( epact = 25 and goldenNumber > 11 ) ) then epact ++ ' final tweaks
end if
fullMoon = 44 - epact ' find first full moon in March
if fullMoon < 21 then fullMoon += 30 ' not before 21 March
easter = fullMoon + 7 - ( ( leapDays + fullMoon ) mod 7 ) ' find Sunday after first full moon in March
if easter < 32
s = fn StringWithFormat( @"%u March", easter )
else
s = fn StringWithFormat( @"%u April", easter - 31 )
end if
end fn = s
 
void local fn showOff
NSInteger year
CFMutableStringRef s = @"", t
for year = 532 to 2100 ' 532 is first year of Dionysius' tables
t = fn StringWithFormat( @"%u%@%@\n", year, @" ", fn easter( year) )
s = fn StringByAppendingString( s, t )
next
s = left( s, len( s ) - 1 ) ' cosmetic: remove last line feed
TextSetString( _showOff, s )
end fn
 
void local fn doEvents( evt as Long, tag as Long )
NSInteger t
select evt
case _textFieldDidChange
ControlSetStringValue ( _outField, @"" )
t = fn ControlIntegerValue( _inField )
if t > 531 then ControlSetStringValue ( _outField, fn easter( t ) )
case _windowShouldClose : end
end select
end fn
 
fn buildInterface
fn showOff
on dialog fn doEvents
 
handleevents
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
</syntaxhighlight>
{{output}}
[[File:Easter.jpg]]
 
In '''[https://formulae.org/?example=Holidays_related_to_Easter this]''' page you can see the program(s) related to this task and their results.
 
=={{header|Go}}==
{{trans|ALGOL 68}}
This solution takes the ALGOL 68 as a reference solution, using its math for calculating the holidays, and reproducing its output.
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,919 ⟶ 2,323:
newEasterRelated(y).print()
}
}</langsyntaxhighlight>
Output:
<pre>
Line 1,962 ⟶ 2,366:
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].
 
<langsyntaxhighlight Iconlang="icon">link printf
 
procedure main()
Line 2,026 ⟶ 2,430:
}
return dr
end</langsyntaxhighlight>
 
Output:<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Line 2,077 ⟶ 2,481:
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:
 
<langsyntaxhighlight lang="j">jed=:3 :0
pfm=. 21 + 30 | _4 + 19 * 1 + 19|y
sn=. 6 - 7 | 4 + <.@*&1.25 y
dys=. 1 40 50 50 +/~sn (] + 7 | 4 + -) pfm
y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys
)</langsyntaxhighlight>
 
Required example:
 
<langsyntaxhighlight lang="j"> jed (400 + 100* i.17),(2010 + i.11),2100</langsyntaxhighlight>
output:
<pre style="height: 24ex; overflow: scroll"> 400 4 1
Line 2,239 ⟶ 2,643:
Nevertheless, here is an implementation which reproduces those numbers, based on the same resource I used for the Julian easters:
 
<langsyntaxhighlight lang="j">ged=:3 :0
ce =. <. y%100
GN =. 1 + 19 | y
Line 2,249 ⟶ 2,653:
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
)</langsyntaxhighlight>
 
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):
 
<langsyntaxhighlight lang="j"> ged (400 + 100* i.17),(2010 + i.11),2100</langsyntaxhighlight>
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
Line 2,431 ⟶ 2,835:
=={{header|Java}}==
Translation of C Sharp via D
<langsyntaxhighlight lang="java">import java.text.DateFormatSymbols;
import java.util.*;
 
Line 2,489 ⟶ 2,893:
System.out.println();
}
}</langsyntaxhighlight>
 
Output:
Line 2,528 ⟶ 2,932:
=={{header|JavaScript}}==
(English version courtesy of google translate below)
<langsyntaxhighlight lang="javascript">const Пасха = год => {
let дата = (год % 19 * 19 + 15) % 30;
дата += (год % 4 * 2 + год % 7 * 4 + 6 * дата + 6) % 7;
Line 2,546 ⟶ 2,950:
);
}
</syntaxhighlight>
</lang>
 
Output:
Line 2,580 ⟶ 2,984:
=== English version ===
(same output)
<langsyntaxhighlight lang="javascript">const Easter = year => {
let date = (year % 19 * 19 + 15) % 30;
date += (year % 4 * 2 + year % 7 * 4 + 6 * date + 6) % 7;
Line 2,597 ⟶ 3,001:
}).join("; ") + ".<br />"
);
}</langsyntaxhighlight>
 
=== Universal algorithm ===
<langsyntaxhighlight lang="javascript">function getEasterDate(year = new Date().getFullYear(), church = 1, calendar = year < 1918 ? 1 : 2) {
/* year: a number of the year (from 325 CE);
church: an algorithm of the computus,
Line 2,654 ⟶ 3,058:
 
for (let year = 400; year <= 2100; year += year < 2000 ? 100 : year >= 2021 ? 80 : year < 2010 ? 10 : 1)
document.write(getHolidaysDates(year, 1) + " <br />");</langsyntaxhighlight>
 
# https://rosettacode.org/wiki/Holidays_related_to_Easter
 
=={{header|jq}}==
'''Works with gojq, the Go implementation of jq'''
 
'''Also works with fq, a Go implementation of a large subset of jq'''
 
'''Adapted from [[#Wren|Wren]]'''
 
This entry uses jq's `mktime` and `gmtime` functions. Unfortunately,
the implementation of `mktime` in the C implementation of jq does not
currently (jq 1.6) support years before 1900.
<syntaxhighlight lang=jq>
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
# add the number of days to [year, month, day]
def addDays($days):
. as [$y,$m,$d]
| [$y,$m,$d + $days,0,0,0,0,0] | mktime | gmtime ;
 
# Output: [year, month_indexed_by_0, day]
def calculateEaster:
. as $year
| {}
| .a = $year % 19
| .b = (($year / 100)|floor)
| .c = $year % 100
| .d = ((.b / 4)|floor)
| .e = .b % 4
| .f = (((.b + 8) / 25)|floor)
| .g = (((.b - .f + 1) / 3)|floor)
| .h = (19 * .a + .b - .d - .g + 15) % 30
| .i = ((.c / 4)|floor)
| .k = .c % 4
| .l = (32 + 2 * .e + 2 * .i - .h - .k) % 7
| .m = (((.a + 11 * .h + 22 * .l) / 451)|floor)
| .n = .h + .l - 7 * .m + 114
| .month = ((.n / 31)|floor) # months indexed from 1
| .day = (.n % 31) + 1
| [$year, .month - 1, .day] ;
 
def holidayOffsets: [
["Easter", 0],
["Ascension", 39],
["Pentecost", 49],
["Trinity", 56],
["C/Christi", 60]
];
 
# Input: year
def outputHolidays:
calculateEaster as $date
| holidayOffsets[] as [$h, $o]
| $date | addDays($o) | strftime("%d %b") ;
 
def tables:
def row: "\(lpad(4)) \([outputHolidays] | join(" "))";
"Year Easter Ascension Pentecost Trinity C/Christi",
" CE Sunday Thursday Sunday Sunday Thursday ",
"---- ------ --------- --------- ------- ---------",
( range(400; 2101; 100) | row),
"",
( range(2010; 2021) | row) ;
 
tables
</syntaxhighlight>
'''Invocation''': gojq -nr -f holidays-related-to-easter.jq
{{output}}
Except for whitespace, the output is identical to that shown in the [[#Wren|Wren]] entry.
 
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia"># v0.6
 
using Dates
Line 2,699 ⟶ 3,175:
for yr in 2010:2020
println(holiday2str(yr))
end</langsyntaxhighlight>
 
{{out}}
Line 2,738 ⟶ 3,214:
=={{header|Kotlin}}==
{{trans|C#}}
<langsyntaxhighlight lang="scala">// version 1.1.2
 
import java.util.Calendar
Line 2,795 ⟶ 3,271:
println()
for (year in 2010..2020) outputHolidays(year)
}</langsyntaxhighlight>
 
{{out}}
Line 2,836 ⟶ 3,312:
=={{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.
<langsyntaxhighlight Lualang="lua">local Time = require("time")
 
function div (x, y) return math.floor(x / y) end
Line 2,873 ⟶ 3,349:
print("Year\tEaster\tAscen.\tPent.\tTrinity\tCorpus")
for year = 1600, 2100, 100 do show(year, holidays(year)) end
for year = 2010, 2020 do show(year, holidays(year)) end</langsyntaxhighlight>
Output:
<pre>Year Easter Ascen. Pent. Trinity Corpus
Line 2,895 ⟶ 3,371:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Needs["Calendar`"];DateFormat[x_]:=DateString[x,{"DayNameShort"," ","DayShort"," ","MonthName"}]
Map[StringJoin[ToString[#]," Easter: ",DateFormat[EasterSunday[#]],
", Ascension: ",DateFormat[DaysPlus[EasterSunday[#],39]],
Line 2,932 ⟶ 3,408:
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,
2020 Easter: Sun 12 April, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 June, Corpus: Thu 11 June}</langsyntaxhighlight>
 
=={{header|Maxima}}==
<langsyntaxhighlight lang="maxima">/* Easter sunday. Result is a list [month, day]
 
See:
Line 2,945 ⟶ 3,421:
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),
[n,p]:divide(h+l-7*m+114,31),[n,p+1])$</langsyntaxhighlight>
 
=={{header|МК-61/52}}==
<syntaxhighlight lang="mk-61">П2 1 9 ПП 86 90 П3 ИП2 4 ПП 86 90
П4 ИП2 7 ПП 86 90 П5 1 9 ИП3 *
1 5 + 3 0 ПП 86 90 П6 2 ИП4
* 4 ИП5 * + 6 ИП6 * + 6
+ 7 ПП 86 90 ИП6 + П1 3 П4 ИП2
1 - 2 10^x / [x] ^ ^ 4 /
[x] - 2 0 + ИП1 + П3 3 1
- /-/ x>=<0 76 78 |x| П3 КИП4 KИП4 ИП3 3 0 - x>= 0
83 - /-/ x<0 87 |x| П3 КИП4 KИП4 ИП3 ИП4 С/П П0 <-> П1 <->
П0 <-> П1 <-> / [x] ИП0 * ИП1 - /-/ В/О</lang>
/-/ В/О</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.
 
For the subsequent calculation of Ascension and Pentecost (Trinity Day):
 
<syntaxhighlight lang="text">П0 <-> П1 <-> - 1 3 + П1 3
1 - /-/ x>=<0 19 21 |x| П1 ИП0 1 + П0 ИП0
П0 ИП0 1 + П0 ИП1 ИП0 С/П ИП1 1 0 +
0 + П1 3 1 - /-/ x<0 45 |x|
П1 3 1 - x>=0 41 П1 ИП0 1 +
П1 ИП0 1 + П0 ИП1 ИП0 С/П</langsyntaxhighlight>
 
''Example'': Easter in 2014 is 20.04; Ascension is 29.05; Pentecost is 08.06.
Line 2,975 ⟶ 3,452:
=={{header|Nim}}==
{{trans|Kotlin}}
<langsyntaxhighlight Nimlang="nim">import strformat, strutils, times
 
const HolidayOffsets = {"Easter": 0, "Ascension": 39, "Pentecost": 49,
Line 3,015 ⟶ 3,492:
for year in countup(400, 2100, 100): outputHolidays(year)
echo ""
for year in 2010..2020: outputHolidays(year)</langsyntaxhighlight>
 
{{out}}
Line 3,055 ⟶ 3,532:
Code handles Gregorian / Julian holidays and dates correctly. Calendar reform was 1582-10-04.
 
<langsyntaxhighlight lang="parigp">/*
* Normalized Julian Day Number from date (base 1899-12-30 00:00:00)
* D = Vec [year, month, day]
Line 3,135 ⟶ 3,612:
print("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:");
for (y = 2010, 2020, holiday(y));
</syntaxhighlight>
</lang>
 
Output:
Line 3,178 ⟶ 3,655:
 
 
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; use warnings;
Line 3,242 ⟶ 3,719:
 
cholidays($_) for(2010..2020);
</syntaxhighlight>
</lang>
 
Output:
Line 3,282 ⟶ 3,759:
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)
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<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>
Line 3,339 ⟶ 3,816:
<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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 3,376 ⟶ 3,853:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/cal.l") # For 'easter' function
 
(de dayMon (Dat)
Line 3,390 ⟶ 3,867:
", Pentecost: " (dayMon (+ E 49))
", Trinity: " (dayMon (+ E 56))
", Corpus: " (dayMon (+ E 60)) ) ) )</langsyntaxhighlight>
Output:
<pre> 400 Easter: Sun 2 Apr, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus: Thu 1 Jun
Line 3,423 ⟶ 3,900:
 
=={{header|PL/I}}==
<syntaxhighlight lang="text">(subscriptrange, size, fofl):
Easter: procedure options (main);
declare months(12) character (9) varying static initial (
Line 3,464 ⟶ 3,941:
end Easter_Sunday;
 
end Easter;</langsyntaxhighlight>
Results:
<pre>
Line 3,491 ⟶ 3,968:
 
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
function Get-Easter
{
Line 3,563 ⟶ 4,040:
}
}
</syntaxhighlight>
</lang>
<syntaxhighlight lang="powershell">
<lang PowerShell>
$years = for ($i = 400; $i -le 2100; $i+=100) {$i}
$years0400to2100 = $years | Get-Easter
Line 3,573 ⟶ 4,050:
Write-Host "Christian holidays, related to Easter, for years from 2010 to 2020 AD:"
$years2010to2020 | Format-Table
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,618 ⟶ 4,095:
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">DataSection
C_DAYS:
Data.i 0,39,49,56,60
Line 3,692 ⟶ 4,169:
PrintN("")
For i=2010 To 2020 : PutTab(i) : PrintN(r$) : Next
Input()</langsyntaxhighlight>
{{out}}
<pre>Year Easter Ascension Pentecost Trinity C/Christi
Line 3,734 ⟶ 4,211:
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.
 
<langsyntaxhighlight lang="python">from dateutil.easter import *
import datetime, calendar
 
Line 3,769 ⟶ 4,246:
print_holidays(get_holiday_values(year))
 
</syntaxhighlight>
</lang>
 
Output:
Line 3,805 ⟶ 4,282:
2019 Easter: Sun 21 Apr, Ascension: Thu 30 May, Pentecost: Sun 9 Jun, Trinity: Sun 16 Jun, Corpus: Thu 20 Jun
2020 Easter: Sun 12 Apr, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 Jun, Corpus: Thu 11 Jun
</pre>
 
=={{header|Quackery}}==
 
Julian calendar for dates prior to 1583CE, Gregorian calendar thereafter.
 
<syntaxhighlight lang="Quackery">
[ dup 19 mod 19 *
15 + 30 mod
swap dup 4 mod 2 *
swap 7 mod 4 * +
over - 34 + 7 mod +
114 + 31 /mod 1+ ] is julian ( y --> m d )
 
[ dup 19 mod 19 *
over 100 / +
over 400 / -
swap 100 / 8 * 13 +
25 / - 15 + 30 mod ] is hge ( y --> n )
 
[ dup 100 / 4 mod 2 * 32 +
over 100 mod 4 / 2 * +
over hge -
swap 4 mod - 7 mod ] is lge ( y --> n )
 
[ dup 19 mod
over hge 11 * +
swap lge 19 * + 443 / ] is mge ( y --> n )
 
[ dup hge
over lge +
swap mge 7 * -
90 + 25 / ] is nge ( y --> n )
 
[ dup hge
over lge +
over mge 7 * +
swap nge 33 * +
19 + 32 mod ] is pge ( y --> n )
 
[ dup nge swap pge ] is gregorian ( y --> m d )
 
[ dup 1583 < iff
julian
else gregorian ] is easter ( y --> m d )
 
[ dip 1+ 9 +
dup 31 > if
[ dip 1+ 31 - ] ] is ascension ( m d --> )
 
[ dip 1+ 19 +
dup 31 > if
[ dip 1+ 31 - ] ] is pentecost ( m d --> )
 
[ dip 1+ 26 +
dup 31 > if
[ dip 1+ 31 - ] ] is trinity ( m d --> )
 
[ dip 1+ 30 +
dup 31 > if
[ dip 1+ 31 - ] ] is corpus ( m d --> )
 
[ swap 3 -
[ table
$ "Mar" $ "Apr"
$ "May" $ "Jun" ]
do echo$ sp
dup 10 < if [ say "0" ]
echo ] is echodate ( m d --> )
 
[ dup 1000 < if sp
dup echo say " "
easter 2dup echodate
say " "
2dup ascension echodate
say " "
2dup pentecost echodate
say " "
2dup trinity echodate
say " "
corpus echodate cr ] is echodates ( y --> )
 
say "Year Easter Ascension Trinity Corpus"
cr
say "(CE) Sunday Thursday Pentecost Sunday Christi"
cr cr
18 times
[ i^ 100 * 400 + echodates ]
cr
11 times
[ i^ 2010 + echodates ]</syntaxhighlight>
 
{{out}}
 
Output concurs with the [[Holidays_related_to_Easter#Western_holidays|bc Western holidays]] entry.
 
<pre>Year Easter Ascension Trinity Corpus
(CE) Sunday Thursday Pentecost Sunday Christi
 
400 Apr 01 May 10 May 20 May 27 May 31
500 Apr 02 May 11 May 21 May 28 Jun 01
600 Apr 10 May 19 May 29 Jun 05 Jun 09
700 Apr 11 May 20 May 30 Jun 06 Jun 10
800 Apr 19 May 28 Jun 07 Jun 14 Jun 18
900 Apr 20 May 29 Jun 08 Jun 15 Jun 19
1000 Mar 31 May 09 May 19 May 26 May 30
1100 Apr 01 May 10 May 20 May 27 May 31
1200 Apr 09 May 18 May 28 Jun 04 Jun 08
1300 Apr 10 May 19 May 29 Jun 05 Jun 09
1400 Apr 18 May 27 Jun 06 Jun 13 Jun 17
1500 Apr 19 May 28 Jun 07 Jun 14 Jun 18
1600 Apr 02 May 11 May 21 May 28 Jun 01
1700 Apr 11 May 20 May 30 Jun 06 Jun 10
1800 Apr 13 May 22 Jun 01 Jun 08 Jun 12
1900 Apr 15 May 24 Jun 03 Jun 10 Jun 14
2000 Apr 23 Jun 01 Jun 11 Jun 18 Jun 22
2100 Mar 28 May 06 May 16 May 23 May 27
 
2010 Apr 04 May 13 May 23 May 30 Jun 03
2011 Apr 24 Jun 02 Jun 12 Jun 19 Jun 23
2012 Apr 08 May 17 May 27 Jun 03 Jun 07
2013 Mar 31 May 09 May 19 May 26 May 30
2014 Apr 20 May 29 Jun 08 Jun 15 Jun 19
2015 Apr 05 May 14 May 24 May 31 Jun 04
2016 Mar 27 May 05 May 15 May 22 May 26
2017 Apr 16 May 25 Jun 04 Jun 11 Jun 15
2018 Apr 01 May 10 May 20 May 27 May 31
2019 Apr 21 May 30 Jun 09 Jun 16 Jun 20
2020 Apr 12 May 21 May 31 Jun 07 Jun 11
</pre>
 
=={{header|R}}==
 
<syntaxhighlight lang="r">
<lang R>
library(tidyverse)
library(lubridate)
Line 3,846 ⟶ 4,452:
`Corpus Christi` = Trinity + 4,
across(.fns = pretty_date))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,890 ⟶ 4,496:
(formerly Perl 6)
{{trans|Perl}}
<syntaxhighlight lang="raku" perl6line>my @abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >;
my @holidays =
Line 3,929 ⟶ 4,535:
for flat (400,500 ... 2000), (2010 ... 2020), 2100 -> $year {
cholidays($year);
}</langsyntaxhighlight>
{{out}}
<pre> 400: Easter: 02 Apr, Ascension: 11 May, Pentecost: 21 May, Trinity: 28 May, Corpus: 01 Jun
Line 3,962 ⟶ 4,568:
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/* REXX **********************************************************************************
* Test frame for computing Christian (Roman Catholic) holidays, related to Easter
* 16.04.2013 Walter Pachl
Line 4,035 ⟶ 4,641:
month=n%31
day=n//31+1
Return year month day</langsyntaxhighlight>
Output:
<pre>Christian holidays, related to Easter, for each centennial from 400 to 2200 CE:
Line 4,084 ⟶ 4,690:
{{works with|Ruby|1.8.7}}
 
<langsyntaxhighlight lang="ruby">require 'date'
 
def easter_date(year)
Line 4,122 ⟶ 4,728:
400.step(2100, 100).each {|year| emit_dates year}
puts
(2010 .. 2020).each {|year| emit_dates year}</langsyntaxhighlight>
 
outputs
Line 4,160 ⟶ 4,766:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
use std::ops::Add;
 
Line 4,206 ⟶ 4,812:
}
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 4,242 ⟶ 4,848:
=={{header|Scala}}==
{{trans|bc}}
<langsyntaxhighlight lang="scala">import java.util._
import scala.swing._
 
Line 4,302 ⟶ 4,908:
size = new java.awt.Dimension(600, 400)
visible = true
}</langsyntaxhighlight>
 
=={{header|Scheme}}==
<langsyntaxhighlight lang="scheme">; Easter sunday. Result is a list '(month day)
;
; See:
Line 4,325 ⟶ 4,931:
(m (quotient (+ a (* 11 h) (* 22 l)) 451))
(n (+ h l (- 114 (* 7 m)))))
(list (quotient n 31) (+ 1 (remainder n 31)))))</langsyntaxhighlight>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "time.s7i";
include "duration.s7i";
Line 4,414 ⟶ 5,020:
writeHolidays(year);
end for;
end func;</langsyntaxhighlight>
 
Original source of the function easterDate, which uses the Gauss formula: [http://seed7.sourceforge.net/algorith/date.htm#easterDate]
Line 4,456 ⟶ 5,062:
=={{header|Sidef}}==
{{trans|Raku}}
<langsyntaxhighlight lang="ruby">require('Date::Calc')
 
var abbr = < Nil Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >
Line 4,499 ⟶ 5,105:
for year in (400..2100 `by` 100, 2010..2020) {
cholidays(year)
}</langsyntaxhighlight>
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">package require Tcl 8.5; # Advanced date handling engine
 
# Easter computation code from http://www.assa.org.au/edm.html
Line 4,569 ⟶ 5,175:
for {set year 2010} {$year <= 2020} {incr year} {
puts [DateInfo $year]
}</langsyntaxhighlight>
Output:
<pre>
Line 4,608 ⟶ 5,214:
=={{header|TUSCRIPT}}==
For dates before October 15, 1582 the Julian Calendar is taken as basis.
<langsyntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
SET years=*
Line 4,627 ⟶ 5,233:
ENDLOOP
ENDLOOP
</syntaxhighlight>
</lang>
Output:
<pre style='height:30ex;overflow:scroll'>
Line 4,783 ⟶ 5,389:
 
=={{header|VBA}}==
{{trans|Phix}}<langsyntaxhighlight lang="vb">Public dates As Variant
Private Function easter(year_ As Integer) As Date
'-- from https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
Line 4,833 ⟶ 5,439:
show year_
Next year_
End Sub</langsyntaxhighlight>{{out}}
<pre> Easter Ascension Pentecost Trinity Corpus
400 zo 02 apr do 11 mei zo 21 mei zo 28 mei do 01 jun
Line 4,870 ⟶ 5,476:
{{libheader|Wren-date}}
{{libheader|Wren-fmt}}
{{libheader|Wren-traititerate}}
<langsyntaxhighlight ecmascriptlang="wren">import "./date" for Date
import "./fmt" for Fmt
import "./traititerate" for Stepped
 
var holidayOffsets = [
Line 4,922 ⟶ 5,528:
for (year in Stepped.new(400..2100, 100)) outputHolidays.call(year)
System.print()
for (year in 2010..2020) outputHolidays.call(year)</langsyntaxhighlight>
 
{{out}}
9,476

edits