lib/chronic/handlers.rb in chronic-0.6.4 vs lib/chronic/handlers.rb in chronic-0.6.5
- old
+ new
@@ -243,10 +243,44 @@
rescue ArgumentError
nil
end
end
+ # Handle RepeaterDayName RepeaterMonthName OrdinalDay
+ def handle_rdn_rmn_od(tokens, options)
+ month = tokens[1].get_tag(RepeaterMonthName)
+ day = tokens[2].get_tag(OrdinalDay).type
+ year = Chronic.now.year
+
+ return if month_overflow?(year, month.index, day)
+
+ begin
+ start_time = Chronic.time_class.local(year, month.index, day)
+ end_time = Chronic.time_class.local(year, month.index, day + 1)
+ Span.new(start_time, end_time)
+ rescue ArgumentError
+ nil
+ end
+ end
+
+ # Handle RepeaterDayName RepeaterMonthName ScalarDay
+ def handle_rdn_rmn_sd(tokens, options)
+ month = tokens[1].get_tag(RepeaterMonthName)
+ day = tokens[2].get_tag(ScalarDay).type
+ year = Chronic.now.year
+
+ return if month_overflow?(year, month.index, day)
+
+ begin
+ start_time = Chronic.time_class.local(year, month.index, day)
+ end_time = Chronic.time_class.local(year, month.index, day + 1)
+ Span.new(start_time, end_time)
+ rescue ArgumentError
+ nil
+ end
+ end
+
# anchors
# Handle repeaters
def handle_r(tokens, options)
dd_tokens = dealias_and_disambiguate_times(tokens, options)
@@ -300,10 +334,10 @@
span = nil
ordinal.times do
span = repeater.next(:future)
- if span.begin > outer_span.end
+ if span.begin >= outer_span.end
span = nil
break
end
end