diff --git a/lib/ice_cube/time_util.rb b/lib/ice_cube/time_util.rb index 136729c2..8bb1db76 100644 --- a/lib/ice_cube/time_util.rb +++ b/lib/ice_cube/time_util.rb @@ -38,9 +38,13 @@ def self.match_zone(time, reference) # Ensure that this is either nil, or a time def self.ensure_time(time, date_eod = false) case time - when DateTime then time.to_time - when Date then date_eod ? time.to_time.end_of_day : time.to_time - else time + when DateTime + warn "IceCube: DateTime support is deprecated (please use Time)" + time.to_time + when Date + date_eod ? end_of_date(time) : time.to_time + else + time end end diff --git a/spec/examples/rfc_spec.rb b/spec/examples/rfc_spec.rb index ebef0bc6..526b87f7 100644 --- a/spec/examples/rfc_spec.rb +++ b/spec/examples/rfc_spec.rb @@ -22,7 +22,7 @@ schedule.add_recurrence_rule IceCube::Rule.daily(2).until(Time.utc(1997, 12, 24)) dates = schedule.occurrences(Time.utc(1997, 12, 31)) offset = 0 - (DateTime.civil(1997, 9, 2)..DateTime.civil(1997, 12, 24)).each do |date| + (Date.new(1997, 9, 2)..Date.new(1997, 12, 24)).each do |date| dates.should include(Time.utc(date.year, date.month, date.day)) if offset % 2 == 0 dates.should_not include(Time.utc(date.year, date.month, date.day)) if offset % 2 != 0 offset += 1 diff --git a/spec/examples/schedule_spec.rb b/spec/examples/schedule_spec.rb index 2c779e5e..5b6e171e 100644 --- a/spec/examples/schedule_spec.rb +++ b/spec/examples/schedule_spec.rb @@ -12,6 +12,20 @@ schedule.start_time.should == t1 end + it 'initializes with a start_time' do + t1 = Time.local(2013, 2, 14, 0, 32, 0) + schedule = IceCube::Schedule.new(t1) + schedule.start_time.should be_a Time + schedule.start_time.should == t1 + end + + it 'converts initialized DateTime to Time' do + dt = DateTime.new(2013, 2, 14, 0, 32, 0) + schedule = IceCube::Schedule.new(dt) + schedule.start_time.should be_a Time + schedule.start_time.should == dt.to_time + end + describe :duration do it 'should be based on end_time' do @@ -204,9 +218,8 @@ conflict.should be_true end - it 'should return false if conflict is not present and single recurrence and time originally specified as DateTime' do - date = DateTime.new(2020,9,21,11,30,0) - start_time = date.to_time + it 'should return false if conflict is not present and single recurrence and time originally specified as Time' do + start_time = Time.new(2020,9,21,11,30,0) schedule1 = IceCube::Schedule.new(start_time, :duration => IceCube::ONE_HOUR) schedule1.add_recurrence_time(start_time) schedule2 = IceCube::Schedule.new(start_time + IceCube::ONE_HOUR, :duration => IceCube::ONE_HOUR) @@ -336,11 +349,6 @@ start_time = Time.utc(Time.now.year + 1, 7, 1, 0, 0, 0).localtime("-05:00") compare_time_zone_info(start_time) end - - it 'should respect time zone info for a DateTime' do - start_time = DateTime.new(Time.now.year + 1, 7, 1, 0, 0, 0, "-05:00") - compare_time_zone_info(start_time) - end end describe :start_date= do