HOLIDAYS = Schedule.new(Date.new(2012,1,1))
HOLIDAYS.add_recurrence_rule Rule.yearly.month_of_year(:october).day_of_month(31)
当我检查 HOLIDAYS.occurs_on 时?对于 10/31/12 我得到 FALSE,但是当我检查 10/30/12 我得到 TRUE。
我究竟做错了什么?
-- 编辑 -- 示例运行
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))
结果是:
[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