Permalink
Browse files

Make #until works correctly with Date objects

Closes #118
  • Loading branch information...
1 parent baaae6d commit b7a265b9765b9a3c5e10ebf86b9c5f1d50d84d7b @seejohnrun committed Nov 13, 2012
Showing with 10 additions and 3 deletions.
  1. +3 −2 lib/ice_cube/time_util.rb
  2. +1 −1 lib/ice_cube/validations/until.rb
  3. +6 −0 spec/examples/regression_spec.rb
@@ -24,9 +24,10 @@ def self.now
end
# Ensure that this is either nil, or a time
- def self.ensure_time(time)
+ def self.ensure_time(time, date_eod = false)
case time
- when Date, DateTime then time.to_time
+ when DateTime then time.to_time
+ when Date then date_eod ? time.to_time.end_of_day : time.to_time
else time
end
end
@@ -11,7 +11,7 @@ def until_time
deprecated_alias :until_date, :until_time
def until(time)
- @until = TimeUtil.ensure_time time
+ @until = time = TimeUtil.ensure_time time, true
replace_validations_for(:until, time.nil? ? nil : [Validation.new(time)])
self
end
@@ -198,4 +198,10 @@
schedule.occurrences_between(start_time, end_time).first.should == start_time
end
+ it 'should include occurrences on until _date_ [#118]' do
+ schedule = IceCube::Schedule.new Time.new(2012, 4, 27)
+ schedule.rrule IceCube::Rule.daily.hour_of_day(12).until(Date.new(2012, 4, 28))
+ schedule.all_occurrences.should == [Time.new(2012, 4, 27, 12), Time.new(2012, 4, 28, 12)]
+ end
+
end

0 comments on commit b7a265b

Please sign in to comment.