diff --git a/app/models/foreman_tasks/recurring_logic.rb b/app/models/foreman_tasks/recurring_logic.rb index f6d3f7996..a30e10aaa 100644 --- a/app/models/foreman_tasks/recurring_logic.rb +++ b/app/models/foreman_tasks/recurring_logic.rb @@ -1,5 +1,5 @@ module ForemanTasks - require 'parse-cron' + require 'fugit' class RecurringLogic < ApplicationRecord include Authorizable @@ -96,11 +96,11 @@ def cancel end def next_occurrence_time(time = Time.zone.now) - @parser ||= CronParser.new(cron_line, Time.zone) + @parser ||= Fugit.parse_cron(cron_line) # @parser.next(start_time) is not inclusive of the start_time hence stepping back one run to include checking start_time for the first run. - before_next = @parser.next(@parser.last(time.in_time_zone)) - return before_next if before_next >= time && tasks.count == 0 - @parser.next(time) + before_next = @parser.next_time(@parser.previous_time(time.iso8601)) + return before_next.utc.localtime if before_next >= time && tasks.count == 0 + @parser.next_time(time).utc.localtime end def generate_delay_options(time = Time.zone.now, options = {}) diff --git a/foreman-tasks.gemspec b/foreman-tasks.gemspec index 32658978c..8260c251a 100644 --- a/foreman-tasks.gemspec +++ b/foreman-tasks.gemspec @@ -27,8 +27,8 @@ same resource. It also optionally provides Dynflow infrastructure for using it f s.extra_rdoc_files = Dir['README*', 'LICENSE'] s.add_dependency "dynflow", '>= 1.6.0' + s.add_dependency 'fugit', '~> 1.8.1' s.add_dependency "get_process_mem" # for memory polling - s.add_dependency "parse-cron", '~> 0.1.4' s.add_dependency "sinatra" # for Dynflow web console s.add_development_dependency 'factory_bot_rails', '~> 4.8.0'