Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolve github issue 6

  • Loading branch information...
commit 1dfa752ec39b047d3b6d28a99eb73c214b3f3ba6 1 parent 3b3fd80
John Crepezzi authored
View
10 lib/ice_cube/rule_occurrence.rb
@@ -22,10 +22,6 @@ def between(begin_time, end_time)
find_occurrences { |roc| roc > end_time }.select { |d| d >= begin_time }
end
- def occurring_at?(time)
-
- end
-
def upto(end_date)
find_occurrences { |roc| roc > end_date }
end
@@ -47,6 +43,7 @@ def succ
end
#walk through all of the successive dates, looking for the next occurrence (interval-valid), then return it.
begin
+ return nil if yield(date)
return nil if @end_time && date > @end_time
return nil if @rule.until_date && date > @rule.until_date # until check
return RuleOccurrence.new(@rule, @start_date, @end_time, date, @index + 1) if @rule.in_interval?(date, @start_date)
@@ -57,15 +54,14 @@ def succ
private
- def find_occurrences
+ def find_occurrences(&block)
include_dates = []
roc = self
begin
break if roc.nil? #go until we run out of dates
next if roc.to_time.nil? #handle the case where start_date is not a valid occurrence
- break if yield(roc) #recurrence condition
include_dates << roc.to_time
- end while roc = roc.succ
+ end while roc = roc.succ(&block)
include_dates
end
View
6 spec/examples/ice_cube_spec.rb
@@ -501,4 +501,10 @@
schedule.occurring_at?((DAY + 4*ONE_DAY + 10).to_date).should be(false) # out of range
end
+ it 'should not create an infinite loop crossing over february - github issue 6' do
+ schedule = Schedule.new(Time.parse('2010-08-30'))
+ schedule.add_recurrence_rule Rule.monthly(6)
+ schedule.occurrences_between(Time.parse('2010-07-01'), Time.parse('2010-09-01'))
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.