From 065a262858df6ed6f79d7c2bd61a1346b6ab4ccc Mon Sep 17 00:00:00 2001 From: Rob Cameron Date: Thu, 14 Nov 2019 17:10:38 -0800 Subject: [PATCH] Allows usage of ISO8601 Duration strings for `run_every` When setting `run_every` you can pass an ISO8601 Duration string like `P1M` which will use ActiveSupport::Duration's built-in parser to turn it into a Rails `1.month` duration object. See https://en.wikipedia.org/wiki/ISO_8601#Durations for full spec. --- lib/delayed/recurring_job.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/delayed/recurring_job.rb b/lib/delayed/recurring_job.rb index e87cb9a..2a3756b 100644 --- a/lib/delayed/recurring_job.rb +++ b/lib/delayed/recurring_job.rb @@ -84,6 +84,8 @@ def deserialize_duration(serialized) case serialized when Hash ActiveSupport::Duration.new(serialized[:value], serialized[:parts]) + when /^P/ + ActiveSupport::Duration.parse(serialized) else serialized end