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
···
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
No! I insist that you top post!*
Oh, and for some actual content:
Date of Easter - Wikipedia
Good luck with that.
Martin Fowler had an article/series of articles on building a DSL for recurring dates. You might want to investigate.
Devin
Mat Schaffer 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 Devin 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.
--Jeremy
Sounds neat. Just please bottom post when replying 
-Mat
* I'm joking, mostly. I use Thunderbird, ATM, so top posts are much more convenient for me. I know, I know, majority rules... just... trim, if you bottom post.
Devin
···
On Jan 2, 2007, at 2:37 PM, Jeremy McAnally wrote:
Mat Schaffer 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.
Yeah, I think you're right about the cweek. You're also right about
this implementation not being very extensible.
On a side note, I was thinking of something like this for a theoretical
layout:
lib/
date/
holiday/
us.rb
uk.rb
jp.rb
...
And then the end user would simply do "require 'date/holiday/us'" to
get the US holidays, etc. I'm not certain, though.
Regards,
Dan
PS - The Date#national_holiday? method I posted is wrong. There should
be "||" not "&&" between the method checks.
···
On Jan 2, 2007, at 2:55 PM, Daniel Berger wrote: