Holidays related to Easter: Difference between revisions

m
(Initial solution for R)
m (→‎{{header|Wren}}: Minor tidy)
 
(30 intermediate revisions by 17 users not shown)
Line 7:
:::*   [[wp:Pentecost|Pentecost]]
:::*   [[wp:Trinity Sunday|Trinity Sunday]]
:::*   [[wp:Corpus Christi (feast)|Corpus Christi feast]] (for Catholic)
:::*   [[wp:All Saints' Sunday|All Saints' Sunday]] (for Orthodox)
 
 
Line 17 ⟶ 18:
From the year 325 CE on,   [[wp:Easter Sunday|Easter Sunday]]   has been defined as the first Sunday ''after'' the first full moon ''on or after'' the day of the March equinox. However, the actual astronomical values for the moments of the full moon and equinox are not used. Instead, approximations are used, the first one being that the equinox is assumed to fall on March 21st every year. The tracking of the moon phases is similarly done with relatively straightforward arithmetic (compared to the sort required for astronomical accuracy) which amounts to maintaining a lunisolar calendar in parallel to our standard purely-solar one.
 
When Pope Gregory reformed the Catholic calendar in 1582 CE, the drifting of Easter with respect to the seasons was the driving motivation, and the rules for determining it (called the <i>computus</i>) were altered to correct that drift. Catholic nations adopted both the new calendar and the new Easter rulescomputus right away, while Western Protestant nations adopted them more gradually over the next 350 years or so. Eventually, even nations dominated by the Eastern Orthodox church adopted a similar calendar reform (the Revised Julian calendar), so pretty much the whole world agrees on what day it is for civil purposes. But the Eastern churches never adopted the corresponding Easter rule changes; they still use the original Julian calendar and rulescomputus to determine the date of what is known in the West as "Orthodox Easter". Therefore, your output should indicate which computus was used to calculate the dates and, at least for historical dates where the calendar can't be assumed or is location-dependent, which calendar those dates are given in.
 
You may find algorithms on the [[wp:Computus|Computus]] Wikipedia page. Some of the results:
 
In the year 400 CE, Easter Sunday was April 1st (in the contemporary Julian calendar), making Ascension Thursday May 10th and Pentecost May 20th. It is ahistorical to give a date so far back for either Trinity Sunday or Corpus Christi, neither of which were observed until centuries later, but they would have been May 27th and 31st. If you extend the modern civil calendar back that far, those days are instead assigned the subsequent dates: Easter on April 2nd, Ascension on May 11th, Pentecost on May 21st.
 
Skipping forward to the year 2100 CE, assuming the rules don't change between now and then, the Western churches will observe Easter on March 28, Ascension Thursday May 6th, Pentecost May 16th, Trinity Sunday May 23rd and Corpus Christi May 27th. Heading East, the Orthodox rules place Easter on April 18 in the original Julian calendar; the corresponding civil date is May 2nd. That puts the Ascension on June 10th and Pentecost June 20th. Orthodox Trinity Sunday is the same day as Pentecost, but they observe All Saints' Sunday the following week, June 27th. Corpus Christi is a purely Catholic date that has no Orthodox version.
 
;Test values of Easter dates:
{| class="wikitable"
! Year
! Orthodox
! Catholic
! Calendar
|-
|400
|01 Apr
| —
|Jul.
|-
|800
|19 Apr
| —
|Jul.
|-
|1200
|09 Apr
| —
|Jul.
|-
|2000
|30 Apr
|23 Apr
|Gr.
|-
|2020
|19 Apr
|12 Apr
|Gr.
|}
 
Skipping forward to the year 2100 CE, assuming the rules don't change between now and then, the Western churches will observe Easter on March 28, Ascension Thursday May 6th, Pentecost May 16th, Trinity Sunday May 23rd and Corpus Christi May 27th. Heading East, the Orthodox rules place Easter on April 18 in the original Julian calendar; the corresponding civil date is May 2nd. That puts the Ascension on June 10th and Pentecost June 20th. Orthodox Trinity Sunday is the same day as Pentecost, so that's still June 20th, while Corpus Christi is a purely Catholic date that has no Orthodox version.
 
=={{header|360 Assembly}}==
Line 29 ⟶ 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 211 ⟶ 246:
XDEC DS CL12 temp for edit
YREGS
END HOLIDAYS</langsyntaxhighlight>
{{out}}
<pre>
Line 249 ⟶ 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 300 ⟶ 335:
Print_Easter (I);
end loop;
end Main;</langsyntaxhighlight>
 
output:
Line 328 ⟶ 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 449 ⟶ 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 484 ⟶ 519:
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|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}}==
<syntaxhighlight 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
set -e
 
easter() {
(( year=$1 ))
 
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 > 50 ))
do
(( day -= 30 ))
done
 
if (( day > 48 ))
then
(( --day ))
fi
 
(( day = day + 7 - (year + year/4 + day + 1) % 7 ))
 
echo $day
}
 
for year in {1998..2100}
do
(( day=$( easter $year ) ))
if (( day < 32 ))
then
printf "%d-%02d-%02d\n" $year 3 $day
else
(( day -= 31 ))
printf "%d-%02d-%02d\n" $year 4 $day
fi
done
 
</syntaxhighlight>
<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>
 
Line 489 ⟶ 685:
{{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 515 ⟶ 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 545 ⟶ 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 604 ⟶ 800:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
quit</langsyntaxhighlight>
 
{{out}}
Line 642 ⟶ 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 696 ⟶ 892:
for (year = 2010; year <= 2020; year += 1) z = easter(year)
z = easter(2100)
quit</langsyntaxhighlight>
 
{{out}}
Line 735 ⟶ 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 747 ⟶ 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 783 ⟶ 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 904 ⟶ 1,100:
for(year=2010; year<=2020; year++){ easter_related_print(year); }
return 0;
}</langsyntaxhighlight>
Output:
<pre>
Line 944 ⟶ 1,140:
{{works with|C sharp|3.0}}
 
<langsyntaxhighlight lang="csharp">using System;
using System.Collections;
using System.Collections.Specialized;
Line 1,001 ⟶ 1,197:
}
}
</syntaxhighlight>
</lang>
 
Output:
Line 1,037 ⟶ 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,164 ⟶ 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,189 ⟶ 1,477:
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">; Easter sunday. Result is a list '(month day)
;
; See:
Line 1,207 ⟶ 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,263 ⟶ 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,300 ⟶ 1,588:
{{libheader| System.SysUtils}}
{{Trans|D}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Holidays_related_to_Easter;
 
Line 1,382 ⟶ 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,426 ⟶ 1,714:
end
 
Holiday.task</langsyntaxhighlight>
 
{{out}}
Line 1,465 ⟶ 1,753:
=={{header|Erlang}}==
{{trans|Elixir}}
<langsyntaxhighlight lang="erlang">-module(holidays).
-export([task/0]).
 
Line 1,527 ⟶ 1,815:
task(Year, Max, Step) ->
holidays(Year),
task(Year+Step, Max, Step).</langsyntaxhighlight>
 
{{out}}
Line 1,570 ⟶ 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,603 ⟶ 1,891:
 
400 2100 100 holidays nl
2010 2020 1 holidays</langsyntaxhighlight>
{{out}}
<pre>
Line 1,641 ⟶ 1,929:
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">
variable year
 
Line 1,691 ⟶ 1,979:
LOOP
;
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,728 ⟶ 2,016:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran"> subroutine easter(year,month,day)
c Easter sunday
c
Line 1,756 ⟶ 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}}
 
'''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
</syntaxhighlight>
{{output}}
[[File:Easter.jpg]]
 
 
=={{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,830 ⟶ 2,323:
newEasterRelated(y).print()
}
}</langsyntaxhighlight>
Output:
<pre>
Line 1,873 ⟶ 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 1,937 ⟶ 2,430:
}
return dr
end</langsyntaxhighlight>
 
Output:<pre>Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:
Line 1,988 ⟶ 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,150 ⟶ 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,160 ⟶ 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,342 ⟶ 2,835:
=={{header|Java}}==
Translation of C Sharp via D
<langsyntaxhighlight lang="java">import java.text.DateFormatSymbols;
import java.util.*;
 
Line 2,400 ⟶ 2,893:
System.out.println();
}
}</langsyntaxhighlight>
 
Output:
Line 2,439 ⟶ 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;
if (год <>= 1918) returnдата new+= Date(год, ...(дата/ >100 9| ?0) [3,- дата(год -/ 9]400 :| [2,0) 22- + дата]))2;
return new Date(год, 2, 22 + дата);
else {
};
const поправка = (год / 100 | 0) - (год / 400 | 0) - 2;
return new Date(год, ...(дата > 39 - поправка ? [4, дата - 39 + поправка] : [3, дата - 9 + поправка]));
}
}
 
for (let год = 400; год <= 2100; год += год < 2000 ? 100 : год >= 2020 ? 80 : год < 2010 ? 10 : 1) {
Line 2,460 ⟶ 2,950:
);
}
</syntaxhighlight>
</lang>
 
Output:
Line 2,494 ⟶ 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;
if (year <>= 1918) date += (year / 100 | 0) - (year / 400 | 0) - 2;
return new Date(year, ...(date > 9 ? [3, date - 9] : [2, 22 + date]));
};
else {
const amendment = (year / 100 | 0) - (year / 400 | 0) - 2;
return new Date(year, ...(date > 39 - amendment ? [4, date - 39 + amendment] : [3, date - 9 + amendment]));
}
}
 
for (let year = 400; year <= 2100; year += year < 2000 ? 100 : year >= 2020 ? 80 : year < 2010 ? 10 : 1) {
Line 2,515 ⟶ 3,001:
}).join("; ") + ".<br />"
);
}</langsyntaxhighlight>
 
=== Universal algorithm ===
<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);
church: an algorithm of the computus,
for Orthodox = 1; for Catholic = 2;
calendar: a calendar of the output date,
Julian = 1; Gregorian = 2. */
if (church == 1) {
let d = (year % 19 * 19 + 15) % 30;
d += (year % 4 * 2 + year % 7 * 4 + 6 * d + 6) % 7;
if (calendar == 1)
return d > 9 ? [d - 9, 4] : [22 + d, 3];
else if (calendar == 2) {
const c = (year / 100 | 0) - (year / 400 | 0) - 2;
return d > 39 - c ? [d - 39 + c, 5] : [d - 9 + c, 4];
}
}
else if (church == 2) {
const
a = year % 19, b = year / 100 | 0, c = year % 100,
d = (19 * a + b - (b / 4 | 0) - ((b - ((b + 8) / 25 | 0) + 1) / 3 | 0) + 15) % 30,
e = (32 + 2 * (b % 4) + 2 * (c / 4 | 0) - d - c % 4) % 7,
f = d + e - 7 * ((a + 11 * d + 22 * e) / 451 | 0) + 114;
if (calendar == 1) {
const
g = f % 31 + 1,
h = (year / 100 | 0) - (year / 400 | 0) - 2;
return g <= h ? [31 + g - h, 3] : [g - h, f / 31 | 0];
}
else if (calendar == 2)
return [f % 31 + 1, f / 31 | 0];
}
}
const
OrthodoxHolidays = [["Easter", 1], ["Ascension", 40], ["Trinity (Pentecost)", 50], ["All Saints' Sunday", 57]],
CatholicHolidays = [["Easter", 1], ["Ascension", 40], ["Pentecost", 50], ["Trinity Sunday", 57], ["Corpus Christi", 61]];
const firstYearOfNewStyle = 1918;
function getHolidaysDates(year = new Date().getFullYear(), church = 1) {
const
Easter = getEasterDate(year, church, year < firstYearOfNewStyle ? 1 : 2),
holidays = church == 1 ? OrthodoxHolidays : CatholicHolidays;
return year + ": " +
holidays.map(h => {
const d = new Date(year, Easter[1] - 1, Easter[0]);
d.setDate(d.getDate() + h[1] - 1);
return h[0] + ": " + new Intl.DateTimeFormat("ru", { month: "numeric", day: "numeric" }).format(d);
}).join("; ") + ".";
}
 
for (let year = 400; year <= 2100; year += year < 2000 ? 100 : year >= 2021 ? 80 : year < 2010 ? 10 : 1)
document.write(getHolidaysDates(year, 1) + " <br />");</syntaxhighlight>
 
# 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,560 ⟶ 3,175:
for yr in 2010:2020
println(holiday2str(yr))
end</langsyntaxhighlight>
 
{{out}}
Line 2,599 ⟶ 3,214:
=={{header|Kotlin}}==
{{trans|C#}}
<langsyntaxhighlight lang="scala">// version 1.1.2
 
import java.util.Calendar
Line 2,656 ⟶ 3,271:
println()
for (year in 2010..2020) outputHolidays(year)
}</langsyntaxhighlight>
 
{{out}}
Line 2,697 ⟶ 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,734 ⟶ 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,755 ⟶ 3,370:
2020 04-12 05-21 05-31 06-07 06-11</pre>
 
=={{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,793 ⟶ 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,806 ⟶ 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,836 ⟶ 3,452:
=={{header|Nim}}==
{{trans|Kotlin}}
<langsyntaxhighlight Nimlang="nim">import strformat, strutils, times
 
const HolidayOffsets = {"Easter": 0, "Ascension": 39, "Pentecost": 49,
Line 2,876 ⟶ 3,492:
for year in countup(400, 2100, 100): outputHolidays(year)
echo ""
for year in 2010..2020: outputHolidays(year)</langsyntaxhighlight>
 
{{out}}
Line 2,916 ⟶ 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 2,996 ⟶ 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,039 ⟶ 3,655:
 
 
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; use warnings;
Line 3,103 ⟶ 3,719:
 
cholidays($_) for(2010..2020);
</syntaxhighlight>
</lang>
 
Output:
Line 3,143 ⟶ 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)
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>--
<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: #000080;font-style:italic;">-- from https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm</span>
--
<span style="color: #004080;">integer</span> <span style="color: #000000;">a</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">,</span><span style="color: #000000;">19</span><span style="color: #0000FF;">),</span>
function easter(integer year)
<span style="color: #000000;">b</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">/</span><span style="color: #000000;">100</span><span style="color: #0000FF;">),</span>
-- from https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
<span style="color: #000000;">c</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">,</span><span style="color: #000000;">100</span><span style="color: #0000FF;">),</span>
integer a = mod(year,19),
<span style="color: #000000;">d</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">b</span><span style="color: #0000FF;">/</span><span style="color: #000000;">4</span><span style="color: #0000FF;">),</span>
b = floor(year/100),
<span style="color: #000000;">e</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">b</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">),</span>
c = mod(year,100),
<span style="color: #000000;">f</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #000000;">b</span><span style="color: #0000FF;">+</span><span style="color: #000000;">8</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">25</span><span style="color: #0000FF;">),</span>
d = floor(b/4),
<span style="color: #000000;">g</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #000000;">b</span><span style="color: #0000FF;">-</span><span style="color: #000000;">f</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">3</span><span style="color: #0000FF;">),</span>
e = mod(b,4),
<span style="color: #000000;">h</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">19</span><span style="color: #0000FF;">*</span><span style="color: #000000;">a</span><span style="color: #0000FF;">+</span><span style="color: #000000;">b</span><span style="color: #0000FF;">-</span><span style="color: #000000;">d</span><span style="color: #0000FF;">-</span><span style="color: #000000;">g</span><span style="color: #0000FF;">+</span><span style="color: #000000;">15</span><span style="color: #0000FF;">,</span><span style="color: #000000;">30</span><span style="color: #0000FF;">),</span>
f = floor((b+8)/25),
<span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">/</span><span style="color: #000000;">4</span><span style="color: #0000FF;">),</span>
g = floor((b-f+1)/3),
<span style="color: #000000;">k</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">),</span>
h = mod(19*a+b-d-g+15,30),
<span style="color: #000000;">l</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">32</span><span style="color: #0000FF;">+</span><span style="color: #000000;">2</span><span style="color: #0000FF;">*</span><span style="color: #000000;">e</span><span style="color: #0000FF;">+</span><span style="color: #000000;">2</span><span style="color: #0000FF;">*</span><span style="color: #000000;">i</span><span style="color: #0000FF;">-</span><span style="color: #000000;">h</span><span style="color: #0000FF;">-</span><span style="color: #000000;">k</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">),</span>
i = floor(c/4),
<span style="color: #000000;">m</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #000000;">a</span><span style="color: #0000FF;">+</span><span style="color: #000000;">11</span><span style="color: #0000FF;">*</span><span style="color: #000000;">h</span><span style="color: #0000FF;">+</span><span style="color: #000000;">22</span><span style="color: #0000FF;">*</span><span style="color: #000000;">l</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">451</span><span style="color: #0000FF;">),</span>
k = mod(c,4),
<span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">h</span><span style="color: #0000FF;">+</span><span style="color: #000000;">l</span><span style="color: #0000FF;">-</span><span style="color: #000000;">7</span><span style="color: #0000FF;">*</span><span style="color: #000000;">m</span><span style="color: #0000FF;">+</span><span style="color: #000000;">114</span><span style="color: #0000FF;">,</span>
l = mod(32+2*e+2*i-h-k,7),
<span style="color: #000000;">month</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">/</span><span style="color: #000000;">31</span><span style="color: #0000FF;">),</span>
m = floor((a+11*h+22*l)/451),
<span style="color: #000000;">day</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">31</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span>
n = h+l-7*m+114,
<span style="color: #008080;">return</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">year</span><span style="color: #0000FF;">,</span><span style="color: #000000;">month</span><span style="color: #0000FF;">,</span><span style="color: #000000;">day</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">}</span>
month = floor(n/31),
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
day = mod(n,31)+1
return {year,month,day,0,0,0,0,0,0}
<span style="color: #008080;">constant</span> <span style="color: #000000;">dates</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{</span><span style="color: #008000;">"Easter "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">},</span>
end function
<span style="color: #0000FF;">{</span><span style="color: #008000;">"Ascension"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">39</span><span style="color: #0000FF;">},</span>
 
<span style="color: #0000FF;">{</span><span style="color: #008000;">"Pentecost"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">49</span><span style="color: #0000FF;">},</span>
constant dates = {{"Easter ",0},
<span style="color: #0000FF;">{</span><span style="color: #008000;">"Trinity "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">56</span><span style="color: #0000FF;">},</span>
{"Ascension",39},
<span style="color: #0000FF;">{</span><span style="color: #008000;">"Corpus "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">60</span><span style="color: #0000FF;">}}</span>
{"Pentecost",49},
{"Trinity ",56},
<span style="color: #008080;">constant</span> <span style="color: #000000;">fmt</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">" %12s"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dates</span><span style="color: #0000FF;">))),</span>
{"Corpus ",60}}
<span style="color: #000000;">fmt0</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">" "</span><span style="color: #0000FF;">&</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"\n"</span><span style="color: #0000FF;">,</span>
 
<span style="color: #000000;">fmtN</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"%4d"</span><span style="color: #0000FF;">&</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"\n"</span>
constant fmt = join(repeat(" %12s",length(dates))),
fmt0 = " "&fmt&"\n",
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
fmtN = "%4d"&fmt&"\n"
 
<span style="color: #000000;">set_timedate_formats</span><span style="color: #0000FF;">({</span><span style="color: #008000;">"Ddd ddth Mmm"</span><span style="color: #0000FF;">})</span>
include builtins\timedate.e
 
<span style="color: #008080;">procedure</span> <span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
set_timedate_formats({"Ddd ddth Mmm"})
<span style="color: #008080;">if</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
 
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt0</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">columnize</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dates</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">])</span>
procedure show(integer year)
<span style="color: #008080;">else</span>
if year=0 then
<span style="color: #000000;">timedate</span> <span style="color: #000000;">e</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">easter</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
printf(1,fmt0, columnize(dates,1)[1])
<span style="color: #004080;">sequence</span> <span style="color: #000000;">args</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">year</span><span style="color: #0000FF;">}</span>
else
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dates</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
timedate e = easter(year)
<span style="color: #004080;">string</span> <span style="color: #000000;">d</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">adjust_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">e</span><span style="color: #0000FF;">,</span><span style="color: #000000;">timedelta</span><span style="color: #0000FF;">(</span><span style="color: #000000;">days</span><span style="color: #0000FF;">:=</span><span style="color: #000000;">dates</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">])))</span>
sequence args = {year}
<span style="color: #000000;">args</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">args</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">)</span>
for i=1 to length(dates) do
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
string d = format_timedate(adjust_timedate(e,timedelta(days:=dates[i][2])))
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmtN</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">args</span><span style="color: #0000FF;">)</span>
args = append(args,d)
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
printf(1,fmtN, args)
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #008080;">for</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">=</span><span style="color: #000000;">400</span> <span style="color: #008080;">to</span> <span style="color: #000000;">2100</span> <span style="color: #008080;">by</span> <span style="color: #000000;">100</span> <span style="color: #008080;">do</span>
end procedure
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
show(0)
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
for year=400 to 2100 by 100 do
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)</span>
show(year)
<span style="color: #008080;">for</span> <span style="color: #000000;">year</span><span style="color: #0000FF;">=</span><span style="color: #000000;">2010</span> <span style="color: #008080;">to</span> <span style="color: #000000;">2020</span> <span style="color: #008080;">do</span>
end for
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">year</span><span style="color: #0000FF;">)</span>
show(0)
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
for year=2010 to 2020 do
<!--</syntaxhighlight>-->
show(year)
end for</lang>
{{out}}
<pre>
Line 3,238 ⟶ 3,853:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/cal.l") # For 'easter' function
 
(de dayMon (Dat)
Line 3,252 ⟶ 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,285 ⟶ 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,326 ⟶ 3,941:
end Easter_Sunday;
 
end Easter;</langsyntaxhighlight>
Results:
<pre>
Line 3,353 ⟶ 3,968:
 
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
function Get-Easter
{
Line 3,425 ⟶ 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,435 ⟶ 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,478 ⟶ 4,093:
2020 Sun 12 Apr Thu 21 May Sun 31 May Sun 07 Jun Thu 11 Jun
</pre>
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">DataSection
C_DAYS:
Data.i 0,39,49,56,60
END_C_DAYS:
DAYS_MT:
Data.i 0,31,28,31,30,31,30,31,31,30,31,30,31
END_DAYS_MT:
EndDataSection
 
Dim m.s{3}(12) : PokeS(@m(),"___JanFebMarAprMayJunJulAugSepOctNovDec")
Dim dom.i(12) : CopyMemory(?DAYS_MT,@dom(),?END_DAYS_MT-?DAYS_MT)
Structure tDate : yyyy.i : mm.i : dd.i : EndStructure
Define.tDate DateTime, BufDateTime
 
Procedure.b IsLeap(y.i)
ProcedureReturn Bool( y % 4 = 0 ) & Bool( y % 100 <> 0 ) | Bool( y % 400 = 0 )
EndProcedure
 
Procedure.i DayOfMt(mm.i,yyyy.i)
Shared dom()
If mm=2 And IsLeap(yyyy) : ProcedureReturn 29 : Else : ProcedureReturn dom(mm) : EndIf
EndProcedure
 
Procedure delta(*pDate.tDate,AddDays.i)
*pDate\dd+AddDays
dom.i=DayOfMt(*pDate\mm,*pDate\yyyy)
While *pDate\dd-dom>0
*pDate\mm+1
If *pDate\mm>12 : *pDate\mm=1 : *pDate\yyyy+1 : EndIf
*pDate\dd-dom
dom=DayOfMt(*pDate\mm,*pDate\yyyy)
Wend
EndProcedure
 
Procedure dt(y.i)
a.i=y%19
b.i=y/100
c.i=y%100
d.i=b/4
e.i=b%4
f.i=(b+8)/25
g.i=(b-f+1)/3
h.i=(19*a+b-d-g+15)%30
i.i=c/4
k.i=c%4
l.i=(32+2*e+2*i-h-k)%7
m.i=(a+11*h+22*l)/451
num.i=h+l-7*m+114
mt.i=num/31
dy.i=(num%31)+1
Shared DateTime
DateTime\yyyy=y
DateTime\mm=mt
DateTime\dd=dy
EndProcedure
 
Macro PutTab(i)
dt(i) : BufDateTime=DateTime : r$=RSet(Str(DateTime\yyyy),4)
*p_C_Days=?C_DAYS
While *p_C_Days<?END_C_DAYS
delta(@DateTime,PeekI(*p_C_Days))
r$+Space(5)+RSet(Str(DateTime\dd),2,"0")+" "+m(DateTime\mm)
DateTime=BufDateTime
*p_C_Days+SizeOf(Integer)
Wend
EndMacro
 
OpenConsole()
PrintN("Year"+Space(5)+"Easter Ascension Pentecost Trinity C/Christi")
PrintN(" CE "+Space(5)+"Sunday Thursday Sunday Sunday Thursday")
PrintN("----"+Space(5)+"------ --------- ---------- ------- ---------")
For i=400 To 2100 Step 100 : PutTab(i) : PrintN(r$) : Next
PrintN("")
For i=2010 To 2020 : PutTab(i) : PrintN(r$) : Next
Input()</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|Python}}==
Line 3,485 ⟶ 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,520 ⟶ 4,246:
print_holidays(get_holiday_values(year))
 
</syntaxhighlight>
</lang>
 
Output:
Line 3,556 ⟶ 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,597 ⟶ 4,452:
`Corpus Christi` = Trinity + 4,
across(.fns = pretty_date))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,641 ⟶ 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,680 ⟶ 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,713 ⟶ 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 3,786 ⟶ 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 3,835 ⟶ 4,690:
{{works with|Ruby|1.8.7}}
 
<langsyntaxhighlight lang="ruby">require 'date'
 
def easter_date(year)
Line 3,873 ⟶ 4,728:
400.step(2100, 100).each {|year| emit_dates year}
puts
(2010 .. 2020).each {|year| emit_dates year}</langsyntaxhighlight>
 
outputs
Line 3,908 ⟶ 4,763:
2019: 21 Apr, 30 May, 9 Jun, 16 Jun, 20 Jun
2020: 12 Apr, 21 May, 31 May, 7 Jun, 11 Jun
</pre>
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">
use std::ops::Add;
 
use chrono::{prelude::*, Duration};
 
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
#[allow(clippy::cast_possible_wrap)]
fn get_easter_day(year: u32) -> chrono::NaiveDate {
let k = (f64::from(year) / 100.).floor();
let d = (19 * (year % 19)
+ ((15 - ((13. + 8. * k) / 25.).floor() as u32 + k as u32 - (k / 4.).floor() as u32) % 30))
% 30;
let e =
(2 * (year % 4) + 4 * (year % 7) + 6 * d + ((4 + k as u32 - (k / 4.).floor() as u32) % 7))
% 7;
 
let (month, day) = match d {
29 if e == 6 => (4, 19),
28 if e == 6 => (4, 18),
_ if d + e < 10 => (3, 22 + d + e),
_ => (4, d + e - 9),
};
 
NaiveDate::from_ymd(year as i32, month, day)
}
fn main() {
let holidays = vec![
("Easter", Duration::days(0)),
("Ascension", Duration::days(39)),
("Pentecost", Duration::days(49)),
("Trinity", Duration::days(56)),
("Corpus Christi", Duration::days(60)),
];
for year in (400..=2100).step_by(100).chain(2010..=2020) {
print!("{}: ", year);
for (name, offset) in &holidays {
print!(
"{}: {}, ",
name,
get_easter_day(year).add(*offset).format("%a %d %h")
);
}
println!();
}
}
</syntaxhighlight>
{{out}}
<pre>
400: Easter: Sun 02 Apr, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus Christi: Thu 01 Jun,
500: Easter: Sun 04 Apr, Ascension: Thu 13 May, Pentecost: Sun 23 May, Trinity: Sun 30 May, Corpus Christi: Thu 03 Jun,
600: Easter: Sun 13 Apr, Ascension: Thu 22 May, Pentecost: Sun 01 Jun, Trinity: Sun 08 Jun, Corpus Christi: Thu 12 Jun,
700: Easter: Sun 15 Apr, Ascension: Thu 24 May, Pentecost: Sun 03 Jun, Trinity: Sun 10 Jun, Corpus Christi: Thu 14 Jun,
800: Easter: Sun 23 Apr, Ascension: Thu 01 Jun, Pentecost: Sun 11 Jun, Trinity: Sun 18 Jun, Corpus Christi: Thu 22 Jun,
900: Easter: Sun 28 Mar, Ascension: Thu 06 May, Pentecost: Sun 16 May, Trinity: Sun 23 May, Corpus Christi: Thu 27 May,
1000: Easter: Sun 30 Mar, Ascension: Thu 08 May, Pentecost: Sun 18 May, Trinity: Sun 25 May, Corpus Christi: Thu 29 May,
1100: Easter: Sun 08 Apr, Ascension: Thu 17 May, Pentecost: Sun 27 May, Trinity: Sun 03 Jun, Corpus Christi: Thu 07 Jun,
1200: Easter: Sun 09 Apr, Ascension: Thu 18 May, Pentecost: Sun 28 May, Trinity: Sun 04 Jun, Corpus Christi: Thu 08 Jun,
1300: Easter: Sun 18 Apr, Ascension: Thu 27 May, Pentecost: Sun 06 Jun, Trinity: Sun 13 Jun, Corpus Christi: Thu 17 Jun,
1400: Easter: Sun 20 Apr, Ascension: Thu 29 May, Pentecost: Sun 08 Jun, Trinity: Sun 15 Jun, Corpus Christi: Thu 19 Jun,
1500: Easter: Sun 01 Apr, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus Christi: Thu 31 May,
1600: Easter: Sun 02 Apr, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus Christi: Thu 01 Jun,
1700: Easter: Sun 11 Apr, Ascension: Thu 20 May, Pentecost: Sun 30 May, Trinity: Sun 06 Jun, Corpus Christi: Thu 10 Jun,
1800: Easter: Sun 13 Apr, Ascension: Thu 22 May, Pentecost: Sun 01 Jun, Trinity: Sun 08 Jun, Corpus Christi: Thu 12 Jun,
1900: Easter: Sun 15 Apr, Ascension: Thu 24 May, Pentecost: Sun 03 Jun, Trinity: Sun 10 Jun, Corpus Christi: Thu 14 Jun,
2000: Easter: Sun 23 Apr, Ascension: Thu 01 Jun, Pentecost: Sun 11 Jun, Trinity: Sun 18 Jun, Corpus Christi: Thu 22 Jun,
2100: Easter: Sun 28 Mar, Ascension: Thu 06 May, Pentecost: Sun 16 May, Trinity: Sun 23 May, Corpus Christi: Thu 27 May,
2010: Easter: Sun 04 Apr, Ascension: Thu 13 May, Pentecost: Sun 23 May, Trinity: Sun 30 May, Corpus Christi: Thu 03 Jun,
2011: Easter: Sun 24 Apr, Ascension: Thu 02 Jun, Pentecost: Sun 12 Jun, Trinity: Sun 19 Jun, Corpus Christi: Thu 23 Jun,
2012: Easter: Sun 08 Apr, Ascension: Thu 17 May, Pentecost: Sun 27 May, Trinity: Sun 03 Jun, Corpus Christi: Thu 07 Jun,
2013: Easter: Sun 31 Mar, Ascension: Thu 09 May, Pentecost: Sun 19 May, Trinity: Sun 26 May, Corpus Christi: Thu 30 May,
2014: Easter: Sun 20 Apr, Ascension: Thu 29 May, Pentecost: Sun 08 Jun, Trinity: Sun 15 Jun, Corpus Christi: Thu 19 Jun,
2015: Easter: Sun 05 Apr, Ascension: Thu 14 May, Pentecost: Sun 24 May, Trinity: Sun 31 May, Corpus Christi: Thu 04 Jun,
2016: Easter: Sun 27 Mar, Ascension: Thu 05 May, Pentecost: Sun 15 May, Trinity: Sun 22 May, Corpus Christi: Thu 26 May,
2017: Easter: Sun 16 Apr, Ascension: Thu 25 May, Pentecost: Sun 04 Jun, Trinity: Sun 11 Jun, Corpus Christi: Thu 15 Jun,
2018: Easter: Sun 01 Apr, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus Christi: Thu 31 May,
2019: Easter: Sun 21 Apr, Ascension: Thu 30 May, Pentecost: Sun 09 Jun, Trinity: Sun 16 Jun, Corpus Christi: Thu 20 Jun,
2020: Easter: Sun 12 Apr, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 07 Jun, Corpus Christi: Thu 11 Jun,
</pre>
 
=={{header|Scala}}==
{{trans|bc}}
<langsyntaxhighlight lang="scala">import java.util._
import scala.swing._
 
Line 3,972 ⟶ 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 3,995 ⟶ 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,084 ⟶ 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,126 ⟶ 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,169 ⟶ 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,239 ⟶ 5,175:
for {set year 2010} {$year <= 2020} {incr year} {
puts [DateInfo $year]
}</langsyntaxhighlight>
Output:
<pre>
Line 4,278 ⟶ 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,297 ⟶ 5,233:
ENDLOOP
ENDLOOP
</syntaxhighlight>
</lang>
Output:
<pre style='height:30ex;overflow:scroll'>
Line 4,453 ⟶ 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,503 ⟶ 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,540 ⟶ 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,592 ⟶ 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