I thought of Chronic (a fine library that I use often!); I'm toying
around with it right now and I think I have it figured out (without
using Chronic)...

I'll re-post the code later on...and maybe make a little gem for those
(i.e, four people) who need it. ;)

--Jeremy

On 1/2/07, Mat Schaffer <schapht / gmail.com> wrote:
>
> On Jan 2, 2007, at 11:56 AM, Jeremy McAnally wrote:
>
> > Try this:
> >
> > class Date
> >  def is_national_holiday?
> >     this_year = self.year.to_s
> >     # Not perfect; Thanksgiving and Easter change...
> >     dates = [this_year + '-12-25', this_year + '-12-24', this_year +
> > '-1-1', this_year + '-7-4', this_year + '-11-28']
> >
> >     if (dates.include?(self.to_s)):
> >        return true
> >     else
> >        return false
> >     end
> >   end
> > end
> >
> >
> >
> > irb(main):263:0> christmas = Date.parse('2007-12-25')
> > => #<Date: 4908919/2,0,2299161>
> > irb(main):264:0> christmas.is_national_holiday?
> > => true
> > irb(main):265:0> today = Date.today
> > => #<Date: 4908205/2,0,2299161>
> > irb(main):266:0> today.is_national_holiday?
> > => false
> >
> > Again, it doesn't get Thanksgiving right or others that change like
> > Easter.  If you want, I could hack it in; otherwise, this should get
> > you on the right path. ;)
>
> For those sort of holidays you could use the Chronic gem to parse a
> textual date:
>
> irb(main):010:0> Chronic.parse('4th thursday in november')
> => Thu Nov 22 11:00:00 -0500 2007
>
> Still kind of a shame there isn't just a 'holidays' gem.
>
> -Mat
>
>


-- 
My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/