class Fugit::Cron
def brute_frequency(year=2017)
Nota bene: cron with seconds are not supported.
a leap second on 2016-12-31)
2017 is a non leap year (though it is preceded by
Avoid for "business" use, it's slow.
Mostly used as a #next_time sanity check.
def brute_frequency(year=2017) FREQUENCY_CACHE["#{to_cron_s}|#{year}"] ||= begin deltas = [] t = EtOrbi.make_time("#{year}-01-01") - 1 t0 = nil t1 = nil loop do t1 = next_time(t) deltas << (t1 - t).to_i if t0 t0 ||= t1 break if deltas.any? && t1.year > year break if t1.year - t0.year > 7 t = t1 end Frequency.new(deltas, t1 - t0) end end