fix(cron): consider scheduling precision in all time comparisons

This commit is contained in:
Gregor Kleen 2019-11-19 10:30:08 +01:00
parent 52d634a269
commit 4ded04b80d

View File

@ -207,13 +207,13 @@ nextCronMatch tz mPrev prec now c@Cron{..} = case notAfter of
execRef ref wasExecd cronAbsolute = case execRef' ref wasExecd cronAbsolute of execRef ref wasExecd cronAbsolute = case execRef' ref wasExecd cronAbsolute of
MatchAt t MatchAt t
| t <= ref -> MatchAsap | t <= addUTCTime prec ref -> MatchAsap
other -> other other -> other
execRef' ref wasExecd cronAbsolute = case cronAbsolute of execRef' ref wasExecd cronAbsolute = case cronAbsolute of
CronAsap -> MatchAt ref CronAsap -> MatchAt ref
CronTimestamp{ cronTimestamp = localTimeToUTCTZ tz -> ts } CronTimestamp{ cronTimestamp = localTimeToUTCTZ tz -> ts }
| ref <= ts || not wasExecd -> MatchAt ts | ref <= addUTCTime prec ts || not wasExecd -> MatchAt ts
| otherwise -> MatchNone | otherwise -> MatchNone
CronCalendar{..} -> listToMatch $ do CronCalendar{..} -> listToMatch $ do
let let
@ -341,7 +341,7 @@ nextCronMatch tz mPrev prec now c@Cron{..} = case notAfter of
let localTimeOfDay = TimeOfDay (fromIntegral mCronHour) (fromIntegral mCronMinute) (fromIntegral mCronSecond) let localTimeOfDay = TimeOfDay (fromIntegral mCronHour) (fromIntegral mCronMinute) (fromIntegral mCronSecond)
res = localTimeToUTCTZ tz LocalTime{..} res = localTimeToUTCTZ tz LocalTime{..}
guard $ res >= ref guard $ addUTCTime prec res >= ref
return res return res
CronNotScheduled -> MatchNone CronNotScheduled -> MatchNone