From: Daniel Berger Date: 2007-01-03T04:55:07+09:00 Subject: Re: Detecting holidays Jeremy McAnally wrote: > Well, the way I'm working it out is like AR's dynamic finders. It > will have a few groups of dates hardcoded (like national holidays and > such), but then you can give it new groups in the form hashes of > arrays of dates with named "work_holidays" or "surprise_offdays" and > then call the method like is_a_work_holiday? or is_a_surprise_offday?. > I'm still working on it...I'll post when I've got it done. Actually, once I took a stab at it, I think it's fairly easy for the national holidays IF I'm using Date#cweek correctly and reliably here: require 'date' class Date def thanksgiving? month == 11 && wday == 4 && cweek == 3 end def christmas? month == 12 && day == 25 end def new_years? month == 1 && day == 1 end alias new_year new_years alias new_years_day new_years def memorial_day? if month == 5 && wday == 1 && cweek == 5 end def independence_day? month == 7 && day == 4 end alias fourth_of_july? independence_day? def national_holiday? new_years? && memorial_day? && independence_day? && thanksgiving? && christmas? end end How's that? Regards, Dan