aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar/computus.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/calendar/computus.go')
-rw-r--r--internal/calendar/computus.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/calendar/computus.go b/internal/calendar/computus.go
new file mode 100644
index 0000000..13410cb
--- /dev/null
+++ b/internal/calendar/computus.go
@@ -0,0 +1,23 @@
+package calendar
+
+import "time"
+
+// Easter returns Gregorian Easter Sunday (UTC midnight) via the Anonymous
+// Gregorian algorithm (Meeus/Jones/Butcher).
+func Easter(year int) time.Time {
+ a := year % 19
+ b := year / 100
+ c := year % 100
+ d := b / 4
+ e := b % 4
+ f := (b + 8) / 25
+ g := (b - f + 1) / 3
+ h := (19*a + b - d - g + 15) % 30
+ i := c / 4
+ k := c % 4
+ l := (32 + 2*e + 2*i - h - k) % 7
+ m := (a + 11*h + 22*l) / 451
+ month := (h + l - 7*m + 114) / 31
+ day := ((h + l - 7*m + 114) % 31) + 1
+ return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
+}