# Getting holiday dates?

**URL:** <https://www.ruby-forum.com/t/getting-holiday-dates/54554>\
**Category:** Rails\
**Created:** [March 8, 2006, 12:20pm UTC](https://www.ruby-forum.com/t/getting-holiday-dates/54554 "2006-03-08T12:20:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [March 8, 2006, 12:20pm UTC](https://www.ruby-forum.com/t/getting-holiday-dates/54554/1 "2006-03-08T12:20:43Z")

</div>

Hi, i’m writing a timesheet application in which i need to know when the  
holidays are, (bank holidays, etc)

Is there a very clever way of getting this info that wouldnt require me  
to manually add it to my database??

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [March 8, 2006, 1:37pm UTC](https://www.ruby-forum.com/t/getting-holiday-dates/54554/2 "2006-03-08T13:37:46Z")

</div>

On Wed, Mar 08, 2006 at 12:20:43PM +0100, Chris wrote:  
} Hi, i’m writing a timesheet application in which i need to know when  
the  
} holidays are, (bank holidays, etc)  
}  
} Is there a very clever way of getting this info that wouldnt require  
me  
} to manually add it to my database??

You could retrieve and parse an ical file. Search [icalshare.com](http://icalshare.com) for a  
suitable one.

} Thanks  
} Chris  
–Greg

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [March 8, 2006, 11:08pm UTC](https://www.ruby-forum.com/t/getting-holiday-dates/54554/3 "2006-03-08T23:08:03Z")

</div>

On Wed, Mar 08, 2006 at 12:20:43PM +0100, Chris wrote:

> Hi, i’m writing a timesheet application in which i need to know when the  
> holidays are, (bank holidays, etc)
> 
> Is there a very clever way of getting this info that wouldnt require me  
> to manually add it to my database??

It depends on which set of holidays you’re interested in. For US  
Government holidays, it’s pretty simple: there are fixed and floating  
holidays. The floating holidays fall on the n-th weekday of the  
month, so the third Monday in January for MLK day, the last Monday in  
May for Memorial day, and so forth.

holiday-float 1 1 3 “Martin Luther King Day”  
holiday-float 2 1 3 “President’s Day”  
holiday-float 5 1 -1 “Memorial Day”  
holiday-float 9 1 1 “Labor Day”  
holiday-float 10 1 2 “Columbus Day”  
holiday-float 11 4 4 “Thanksgiving”

Then there are the fixed holidays, which nominally fall on the same  
day each year: January first for New Year’s day, July forth for the  
forth of July, and so forth. The only trick here is that if this day  
falls on a weekend, it gets celebrated on the nearest Friday or Monday.

holiday-fixed 1 1 “New Year’s Day”  
holiday-fixed 7 4 “Independence Day”  
holiday-fixed 11 11 “Veteran’s Day”  
holiday-fixed 12 25 “Christmas”

For a bizarrely complete treatment of this subject, see the  
calendar.el file from a recent distribution of Emacs. These, and a  
huge array of holidays that you’ve never heard of, much less  
celebrated, are all covered in detail.

– John Kodis.

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [March 8, 2006, 11:56pm UTC](https://www.ruby-forum.com/t/getting-holiday-dates/54554/4 "2006-03-08T23:56:51Z")

</div>

In Perl i often used a BusinessDay module (CPAN) for that, which  
incorporated holidays as well. Would be nice if Rails had something  
like:

10.business\_days.from\_now

where business\_days are days counted excluding Sat/Su but also  
excluding holidays (w/ localized settings, of course). Maybe this  
already exists as a plug-in?? In any case, this would be very useful  
for a range of apps.

Sebastian
