diff --git a/lib/holidays.rb b/lib/holidays.rb index c02612e..85f84ce 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -86,10 +86,20 @@ module Holidays # remove the timezone start_date = start_date.new_offset(0) if start_date.respond_to?(:new_offset) end_date = end_date.new_offset(0) if end_date.respond_to?(:new_offset) - - start_date = start_date.to_date if start_date.respond_to?(:to_date) - end_date = end_date.to_date if end_date.respond_to?(:to_date) - + + # get simple dates + if start_date.respond_to?(:to_date) + start_date = start_date.to_date + else + start_date = Date.civil(start_date.year, start_date.mon, start_date.mday) + end + + if end_date.respond_to?(:to_date) + end_date = end_date.to_date + else + end_date = Date.civil(end_date.year, end_date.mon, end_date.mday) + end + regions, observed, informal = parse_options(options) holidays = [] diff --git a/test/test_date.rb b/test/test_date.rb index c4f9e77..fa631c9 100644 --- a/test/test_date.rb +++ b/test/test_date.rb @@ -107,7 +107,8 @@ class DateTests < Test::Unit::TestCase end def test_datetime_holiday? - assert DateTime.now.to_date.holiday?('test') + # in situations with activesupport + assert DateTime.now.to_date.holiday?('test') if DateTime.now.respond_to?(:to_date) assert DateTime.now.holiday?('test') end