Reputation: 9085
HOLIDAYS = Schedule.new(Date.new(2012,1,1))
HOLIDAYS.add_recurrence_rule Rule.yearly.month_of_year(:october).day_of_month(31)
When I check HOLIDAYS.occurs_on? for 10/31/12 I get FALSE, but when I check for 10/30/12 I get TRUE.
What am I doing wrong?
-- edit -- sample run
days = Holidays::HALLOWEEN.occurrences(Date.today)
days.each do |day|
Log.info day
end
Log.info Holidays::HALLOWEEN.occurs_on?(Date.new(2012,10,31))
Log.info Holidays::HALLOWEEN.occurs_on?(Date.new(2012,10,30))
Log.info Holidays::HALLOWEEN.occurs_on?(Date.new(2013,10,31))
Log.info Holidays::HALLOWEEN.occurs_on?(Date.new(2013,10,30))
Results in:
[09:22:15] INFO 2012-10-31 00:00:00 -0400
[09:22:15] INFO 2013-10-31 00:00:00 -0400
[09:22:15] INFO false
[09:22:15] INFO true
[09:22:15] INFO false
[09:22:15] INFO true
Upvotes: 0
Views: 159
Reputation: 9085
By switching from Date.new(2012,10,31) to Time.utc(2012,10,31) I was able to get correct behavior.
Upvotes: 1