Forum: Ruby on Rails getting holiday dates?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-03-08 12:20
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
675475d0b65710be6d992eb5eb2c61c2?d=identicon&s=25 Gregory Seidman (Guest)
on 2006-03-08 13:37
(Received via mailing list)
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 for a
suitable one.

} Thanks
} Chris
--Greg
31b6446447a4da5157bb67cc4c6afc64?d=identicon&s=25 John Kodis (Guest)
on 2006-03-08 23:08
(Received via mailing list)
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.
10c741d575988433e3fcd04133f3c462?d=identicon&s=25 Sebastian Friedrich (Guest)
on 2006-03-08 23:56
(Received via mailing list)
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
This topic is locked and can not be replied to.