summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorJoey Hess2014-04-11 15:00:27 -0400
committerJoey Hess2014-04-11 15:00:27 -0400
commit99ec97db855bbcb7e72b5519193275ac1161bcf9 (patch)
tree68888d564cd980f52fcda5383add6345721dfcdd /Utility
parentbe01532282bdca11e6fc97114206e44872d16eea (diff)
Merge scheduler bug fix from git-annex.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Scheduled.hs46
1 files changed, 23 insertions, 23 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index 11e3b569..2b7cae2b 100644
--- a/Utility/Scheduled.hs
+++ b/Utility/Scheduled.hs
@@ -108,65 +108,65 @@ calcNextTime (Schedule recurrance scheduledtime) lasttime currenttime
window startd endd = NextTimeWindow
(LocalTime startd nexttime)
(LocalTime endd (TimeOfDay 23 59 0))
- findfrom r afterday day = case r of
+ findfrom r afterday candidate = case r of
Daily
- | afterday -> Just $ exactly $ addDays 1 day
- | otherwise -> Just $ exactly day
+ | afterday -> Just $ exactly $ addDays 1 candidate
+ | otherwise -> Just $ exactly candidate
Weekly Nothing
| afterday -> skip 1
- | otherwise -> case (wday <$> lastday, wday day) of
- (Nothing, _) -> Just $ window day (addDays 6 day)
+ | otherwise -> case (wday <$> lastday, wday candidate) of
+ (Nothing, _) -> Just $ window candidate (addDays 6 candidate)
(Just old, curr)
- | old == curr -> Just $ window day (addDays 6 day)
+ | old == curr -> Just $ window candidate (addDays 6 candidate)
| otherwise -> skip 1
Monthly Nothing
| afterday -> skip 1
- | maybe True (\old -> mnum day > mday old && mday day >= (mday old `mod` minmday)) lastday ->
+ | maybe True (\old -> mnum candidate > mnum old && mday candidate >= (mday old `mod` minmday)) lastday ->
-- Window only covers current month,
-- in case there is a Divisible requirement.
- Just $ window day (endOfMonth day)
+ Just $ window candidate (endOfMonth candidate)
| otherwise -> skip 1
Yearly Nothing
| afterday -> skip 1
- | maybe True (\old -> ynum day > ynum old && yday day >= (yday old `mod` minyday)) lastday ->
- Just $ window day (endOfYear day)
+ | maybe True (\old -> ynum candidate > ynum old && yday candidate >= (yday old `mod` minyday)) lastday ->
+ Just $ window candidate (endOfYear candidate)
| otherwise -> skip 1
Weekly (Just w)
| w < 0 || w > maxwday -> Nothing
- | w == wday day -> if afterday
- then Just $ exactly $ addDays 7 day
- else Just $ exactly day
+ | w == wday candidate -> if afterday
+ then Just $ exactly $ addDays 7 candidate
+ else Just $ exactly candidate
| otherwise -> Just $ exactly $
- addDays (fromIntegral $ (w - wday day) `mod` 7) day
+ addDays (fromIntegral $ (w - wday candidate) `mod` 7) candidate
Monthly (Just m)
| m < 0 || m > maxmday -> Nothing
-- TODO can be done more efficiently than recursing
- | m == mday day -> if afterday
+ | m == mday candidate -> if afterday
then skip 1
- else Just $ exactly day
+ else Just $ exactly candidate
| otherwise -> skip 1
Yearly (Just y)
| y < 0 || y > maxyday -> Nothing
- | y == yday day -> if afterday
+ | y == yday candidate -> if afterday
then skip 365
- else Just $ exactly day
+ else Just $ exactly candidate
| otherwise -> skip 1
Divisible n r'@Daily -> handlediv n r' yday (Just maxyday)
Divisible n r'@(Weekly _) -> handlediv n r' wnum (Just maxwnum)
Divisible n r'@(Monthly _) -> handlediv n r' mnum (Just maxmnum)
Divisible n r'@(Yearly _) -> handlediv n r' ynum Nothing
- Divisible _ r'@(Divisible _ _) -> findfrom r' afterday day
+ Divisible _ r'@(Divisible _ _) -> findfrom r' afterday candidate
where
- skip n = findfrom r False (addDays n day)
+ skip n = findfrom r False (addDays n candidate)
handlediv n r' getval mmax
| n > 0 && maybe True (n <=) mmax =
- findfromwhere r' (divisible n . getval) afterday day
+ findfromwhere r' (divisible n . getval) afterday candidate
| otherwise = Nothing
- findfromwhere r p afterday day
+ findfromwhere r p afterday candidate
| maybe True (p . getday) next = next
| otherwise = maybe Nothing (findfromwhere r p True . getday) next
where
- next = findfrom r afterday day
+ next = findfrom r afterday candidate
getday = localDay . startTime
divisible n v = v `rem` n == 0