Skip to content

Commit 3de160c

Browse files
committed
Added EasterForYear
Signed-off-by: Dan S. Camper <[email protected]>
1 parent 80251a8 commit 3de160c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: EasterForYear.ecl

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
IMPORT Std;
2+
3+
/**
4+
* Function returns a date in Std.Date.Date_t format
5+
* representing the date Easter falls on for the
6+
* given year.
7+
*
8+
* @param year Four-digit year; REQUIRED
9+
*
10+
* @return The date Easter falls on in the given
11+
* year, in Std.Date.Date_t format.
12+
*/
13+
EXPORT EasterForYear(INTEGER2 year) := FUNCTION
14+
c := year DIV 100;
15+
g := year % 19;
16+
h := ((c - (c DIV 4) - ((8 * c + 13) DIV 25) + (19 * g) + 15) % 30);
17+
i := (h - (h DIV 28) * (1 - (29 DIV (h + 1)) * ((21-g) DIV 11)));
18+
j := ((year + (year DIV 4) + i + 2 - c + (c DIV 4)) % 7);
19+
l := i - j;
20+
month := (3 + ((l + 40) DIV 44));
21+
day := (l + 28 - 31 * (month DIV 4));
22+
23+
RETURN Std.Date.DateFromParts(year, month, day);
24+
END;
25+
26+
/*
27+
OUTPUT(EasterForYear(2022), NAMED('easter_2022')); // 20220417
28+
OUTPUT(EasterForYear(2023), NAMED('easter_2023')); // 20230409
29+
OUTPUT(EasterForYear(2024), NAMED('easter_2024')); // 20240331
30+
*/

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ own ECL bundle. Please see
3030
* [BWR_ShowPlatformConstants.ecl](BWR/BWR_ShowPlatformConstants.ecl)
3131
* [ConcatFieldValues.ecl](ConcatFieldValues.ecl)
3232
* [DatasetSkew.ecl](DatasetSkew.ecl)
33+
* [EasterForYear.ecl](EasterForYear.ecl)
3334
* [ExportZipArchive.ecl](ExportZipArchive.ecl)
3435
* [Factorial.ecl](Factorial.ecl)
3536
* [FuzzyStringSearch.ecl](FuzzyStringSearch.ecl)

0 commit comments

Comments
 (0)