diff --git a/src/mel/cron_task.cr b/src/mel/cron_task.cr index cc30b1a..6d0b998 100644 --- a/src/mel/cron_task.cr +++ b/src/mel/cron_task.cr @@ -18,7 +18,7 @@ class Mel::CronTask json.field("retries", retries) json.field("attempts", attempts) json.field("schedule", schedule) - json.field("till", till.try(&.to_unix)) if till + json.field("till", till.try(&.to_unix)) end end diff --git a/src/mel/periodic_task.cr b/src/mel/periodic_task.cr index 6788b24..8c750a8 100644 --- a/src/mel/periodic_task.cr +++ b/src/mel/periodic_task.cr @@ -24,7 +24,7 @@ class Mel::PeriodicTask json.field("retries", retries) json.field("attempts", attempts) json.field("interval", interval.total_seconds.to_i64) - json.field("till", till.try(&.to_unix)) if till + json.field("till", till.try(&.to_unix)) end end diff --git a/src/mel/task.cr b/src/mel/task.cr index 67da4a0..e4f0b2a 100644 --- a/src/mel/task.cr +++ b/src/mel/task.cr @@ -207,7 +207,7 @@ module Mel::Task time = Time.unix(json["time"].as_i64) retries = json["retries"].as_i attempts = json["attempts"].as_i - till = json["till"]?.try { |timestamp| Time.unix(timestamp.as_i64) } + till = json["till"]?.try &.as_i64?.try { |timestamp| Time.unix(timestamp) } schedule = json["schedule"]?.try(&.as_s) interval = json["interval"]?.try(&.as_i64.seconds)