class Chronic::RepeaterTime
def next(pointer)
pointer - Symbol representing which temporal direction to fetch the next day
Return the next past or future Span for the time that this Repeater represents
def next(pointer) super half_day = 60 * 60 * 12 full_day = 60 * 60 * 24 first = false unless @current_time first = true midnight = Chronic.time_class.local(@now.year, @now.month, @now.day) yesterday_midnight = midnight - full_day tomorrow_midnight = midnight + full_day offset_fix = midnight.gmt_offset - tomorrow_midnight.gmt_offset tomorrow_midnight += offset_fix catch :done do if pointer == :future if @type.ambiguous? [midnight + @type.time + offset_fix, midnight + half_day + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t| (@current_time = t; throw :done) if t >= @now end else [midnight + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t| (@current_time = t; throw :done) if t >= @now end end else # pointer == :past if @type.ambiguous? [midnight + half_day + @type.time + offset_fix, midnight + @type.time + offset_fix, yesterday_midnight + @type.time + half_day].each do |t| (@current_time = t; throw :done) if t <= @now end else [midnight + @type.time + offset_fix, yesterday_midnight + @type.time].each do |t| (@current_time = t; throw :done) if t <= @now end end end end @current_time || raise("Current time cannot be nil at this point") end unless first increment = @type.ambiguous? ? half_day : full_day @current_time += pointer == :future ? increment : -increment end Span.new(@current_time, @current_time + width) end