From: Mat Schaffer Date: 2007-01-03T05:28:08+09:00 Subject: Re: Detecting holidays On Jan 2, 2007, at 2:55 PM, Daniel Berger wrote: > 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 I think it would be cweek == 4, but I like the idea. This particular implementation doesn't seem very extensible. Not sure what would be the best way to define some sort of custom holidays file that could be read by a gem... Procs in a hash comes to mind. -Mat