Created
March 19, 2024 13:56
-
-
Save raxoft/b6e397686b44f25b7efa51b75b19ea67 to your computer and use it in GitHub Desktop.
Ruby code to compute the date of Easter Sunday for given year.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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