vendor/bundle/ruby/1.8/gems/rufus-scheduler-2.0.16/lib/rufus/sc/cronline.rb
# Returns the next time that this cron line is supposed to 'fire'
#
# This is raw, 3 secs to iterate over 1 year on my macbook :( brutal.
# (Well, I was wrong, takes 0.001 sec on 1.8.7 and 1.9.1)
#
# This method accepts an optional Time parameter. It's the starting point
# for the 'search'. By default, it's Time.now
#
# Note that the time instance returned will be in the same time zone that
# the given start point Time (thus a result in the local time zone will
# be passed if no start time is specified (search start time set to
# Time.now))
#
#   Rufus::CronLine.new('30 7 * * *').next_time(
#     Time.mktime(2008, 10, 24, 7, 29))
#   #=> Fri Oct 24 07:30:00 -0500 2008
#
#   Rufus::CronLine.new('30 7 * * *').next_time(
#     Time.utc(2008, 10, 24, 7, 29))
#   #=> Fri Oct 24 07:30:00 UTC 2008
#
#   Rufus::CronLine.new('30 7 * * *').next_time(
#     Time.utc(2008, 10, 24, 7, 29)).localtime
#   #=> Fri Oct 24 02:30:00 -0500 2008
#
# (Thanks to K Liu for the note and the examples)
#
Returns the next time that this cron line is supposed to 'fire'
This is raw, 3 secs to iterate over 1 year on my macbook :( brutal.

This method accepts an optional Time parameter. It's the starting point
for the 'search'.

Note that the time instance returned will be in the same time zone that
the given start point Time (thus a result in the local time zone will
be passed if no start time is specified (search start time set to
Time.now))







(Thanks to K Liu for the note and the examples)
Returns the next time that this cron line is supposed to ' fire ' This is raw 3 secs to iterate over 1 year on my macbook : ( brutal . This method accepts an optional Time parameter . It ' s the starting point for the ' search ' . Note that the time instance returned will be in the same time zone that the given start point Time ( thus a result in the local time zone will be passed if no start time is specified ( search start time set to Time . now )) ( Thanks to K Liu for the note and the examples )
def next_time(now=Time.now)
      time = @timezone ? @timezone.utc_to_local(now.getutc) : now
      time = time - time.usec * 1e-6 + 1
      loop do
        unless date_match?(time)
          time += (24 - time.hour) * 3600 - time.min * 60 - time.sec
          next
        end
        unless sub_match?(time.hour, @hours)
          time += (60 - time.min) * 60 - time.sec
          next
        end
        unless sub_match?(time.min, @minutes)
          time += 60 - time.sec
          next
        end
        unless sub_match?(time.sec, @seconds)
          time += 1
          next
        end
        break
      end
      if @timezone
        time = @timezone.local_to_utc(time)
        time = time.getlocal unless now.utc?
      end
      time
    end
def next_time ( now = Time . now ) time = @timezone ? @timezone . utc_to_local ( now . getutc ) : now time = time - time . usec * 1e-6 + 1 loop do unless date_match? ( time ) time += ( 24 - time . hour ) * 3600 - time . min * 60 - time . sec next end unless sub_match? ( time . hour , @hours ) time += ( 60 - time . min ) * 60 - time . sec next end unless sub_match? ( time . min , @minutes ) time += 60 - time . sec next end unless sub_match? ( time . sec , @seconds ) time += 1 next end break end if @timezone time = @timezone . local_to_utc ( time ) time = time . getlocal unless now . utc? end time end
Returns the next time that this cron line is supposed to 'fire'
This is raw, 3 secs to iterate over 1 year on my macbook :( brutal.
Returns the next time that this cron line is supposed to ' fire ' This is raw 3 secs to iterate over 1 year on my macbook : ( brutal .
# little adjustment before starting
now