mirror of
https://github.com/plashchynski/crono.git
synced 2026-04-17 22:49:52 +02:00
Period#next should return today time if it is first run and not too late
This commit is contained in:
@@ -56,7 +56,7 @@ module Crono
|
||||
|
||||
logger.info "Jobs:"
|
||||
Crono.scheduler.jobs.each do |job|
|
||||
logger.info job.description
|
||||
logger.info %{"#{job.performer}" with rule "#{job.period.description}" next time will perform at #{job.next}}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,8 +6,13 @@ module Crono
|
||||
end
|
||||
|
||||
def next(since: nil)
|
||||
since ||= Time.now
|
||||
@period.since(since).change({hour: @at_hour, min: @at_min}.compact)
|
||||
if since.nil?
|
||||
@next = Time.now.change(time_atts)
|
||||
return @next if @next.future?
|
||||
since = Time.now
|
||||
end
|
||||
|
||||
@period.since(since).change(time_atts)
|
||||
end
|
||||
|
||||
def description
|
||||
@@ -27,5 +32,10 @@ module Crono
|
||||
raise "Unknown 'at' format"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def time_atts
|
||||
{hour: @at_hour, min: @at_min}.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user