# Proposal: Yet another Date method

**URL:** <https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404>\
**Category:** Ruby\
**Created:** [April 8, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404 "2007-04-08T15:06:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bertram\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bertram\_S](https://www.ruby-forum.com/u/Bertram_S)\
**Post date:** [April 8, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404/1 "2007-04-08T15:06:23Z")

</div>

Hi,

I would like the Date class to be extended by this:

require “date”

class Date  
class \<\<self  
def easter\_western year  
# This is after Donald E. Knuth and it works for both  
# Julian (before 1583) and Gregorian (after 1582) calendars.  
g = year%19 + 1 # golden number  
c = year/100 + 1 # century  
x = (3_c/4) - 12 # corrections  
z = (8_c+5)/25 - 5  
d = 5_year/4 - x - 10 # March((-d)%7)th is Sunday  
e = (11_g + 20 + z - x) % 30 # moon phase  
e += 1 if e == 25 and g \> 11 or e == 24  
n = 44 - e # full moon  
n += 30 if n \< 21  
month = 3  
day = n+7 - (d+n)%7  
if day \> 31 then  
month += 1  
day -= 31  
end  
civil year, month, day  
end  
alias easter easter\_western  
end  
end

I tested it with all easter date tables I found on the web  
in German, English and French.

Happy Easter!

Bertram

---

<div class="post-metadata">

**Author:** ![Bertram\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bertram\_S](https://www.ruby-forum.com/u/Bertram_S)\
**Post date:** [April 8, 2007, 10:00pm UTC](https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404/2 "2007-04-08T22:00:19Z")

</div>

If we are taking a vote on this I vote YES

---

<div class="post-metadata">

**Author:** ![Bertram\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bertram\_S](https://www.ruby-forum.com/u/Bertram_S)\
**Post date:** [April 9, 2007, 4:44am UTC](https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404/3 "2007-04-09T04:44:49Z")

</div>

I wrote something that tests for Easter, Christmas, 4th of July, and  
so on wrapped into a method called “is\_national\_holiday?” that I  
planned on releasing as a gem, but I never did…I still have it if  
you actually need something that doees this.

–Jeremy

On 4/8/07, Bertram S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> # Julian (before 1583) and Gregorian (after 1582) calendars.
> day = n+7 - (d+n)%7
> 
> ```
> 
> I tested it with all easter date tables I found on the web  
> [http://www.bertram-scharpf.de](http://www.bertram-scharpf.de)

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My free Ruby e-book:  
[http://www.humblelittlerubybook.com/book/](http://www.humblelittlerubybook.com/book/)

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)

---

<div class="post-metadata">

**Author:** ![Bertram\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bertram\_S](https://www.ruby-forum.com/u/Bertram_S)\
**Post date:** [April 8, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/proposal-yet-another-date-method/91404/4 "2007-04-08T18:36:39Z")

</div>

Bertram S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Hi,
> 
> I would like the Date class to be extended by this:

cf. ruby-1.8.6/sample/goodfriday.rb
