def previous_time(from=ZoTime.now)
pt = nil
zt = ZoTime.new(from.to_i - 1, @timezone)
miny = from.year - NEXT_TIME_MAX_YEARS
loop do
pt = zt.dup
fail RangeError.new(
"failed to reach occurrence within " +
"#{NEXT_TIME_MAX_YEARS} years for '#{original}'"
) if pt.year < miny
unless date_match?(pt)
zt.substract(pt.hour * 3600 + pt.min * 60 + pt.sec + 1)
next
end
unless sub_match?(pt, :hour, @hours)
zt.substract(pt.min * 60 + pt.sec + 1)
next
end
unless sub_match?(pt, :min, @minutes)
zt.substract(pt.sec + 1)
next
end
unless sub_match?(pt, :sec, @seconds)
zt.substract(prev_second(pt))
next
end
break
end
pt
end