mirror of
https://github.com/plashchynski/crono.git
synced 2026-09-18 07:51:26 +02:00
Period#next should return today time if it is first run and not too late
This commit is contained in:
+12
-2
@@ -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