Skip to content

Instantly share code, notes, and snippets.

@raxoft
Created March 19, 2024 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raxoft/b6e397686b44f25b7efa51b75b19ea67 to your computer and use it in GitHub Desktop.
Save raxoft/b6e397686b44f25b7efa51b75b19ea67 to your computer and use it in GitHub Desktop.
Ruby code to compute the date of Easter Sunday for given year.
# Helper for computing the date of Easter Sunday.
require 'date'
class Date
def self.easter_sunday(year)
a = year % 19
b, c = year.divmod 100
d, e = b.divmod 4
g = (8 * b + 13) / 25
h = (19 * a + b - d - g + 15) % 30
i, k = c.divmod 4
l = (32 + 2 * e + 2 * i - h - k) % 7
m = (a + 11 * h + 22 * l) / 451
month, day = (h + l - 7 * m + 114).divmod 31
new(year, month, day + 1)
end
end
# EOF #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment