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
On Mar 8, 2006, at 4:06 PM, John Kodis wrote:
> 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.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>