summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-11 14:38:23 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-11 14:38:23 -0400
commit9ea0f1feec4ec9d944e332b2656f5c9de75719ea (patch)
tree141675822e48e4e82541f53caca46162b3cb5b91
parent13aed612b704d5284e2e96a588f8767db1a1e612 (diff)
rename confusingly named "day"
-rw-r--r--Utility/Scheduled.hs46
1 files changed, 23 insertions, 23 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index e4b03aac4..2b7cae2b6 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 > mnum 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