summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-07 23:58:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-07 23:58:26 -0400
commita37525eca89aaba94cd21dccd2d285dc7bd34be0 (patch)
treef819746cdb92056004fbd17b6471cab372dcbfaa /Utility
parent7c5aa2fbefbe0aa345dcd8ab0834c4684c3169a3 (diff)
refactor
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Scheduled.hs25
1 files changed, 9 insertions, 16 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index eba5aac49..ee6f831ed 100644
--- a/Utility/Scheduled.hs
+++ b/Utility/Scheduled.hs
@@ -115,23 +115,16 @@ calcNextTime (Schedule recurrance scheduledtime _duration) lasttime currenttime
then findnextday r False (addDays 365 day)
else Just day
| otherwise -> findnextday r False (addDays 1 day)
- Divisible n r'@Daily
- | n > 0 && n <= maxyday ->
- findnextdaywhere r' (divisible n . yday) afterday day
- | otherwise -> Nothing
- Divisible n r'@(Weekly _)
- | n > 0 && n <= maxwnum ->
- findnextdaywhere r' (divisible n . wnum) afterday day
- | otherwise -> Nothing
- Divisible n r'@(Monthly _)
- | n > 0 && n <= maxmnum ->
- findnextdaywhere r' (divisible n . mnum) afterday day
- | otherwise -> Nothing
- Divisible n r'@(Yearly _)
- | n > 0 ->
- findnextdaywhere r' (divisible n . year) afterday day
- | otherwise -> Nothing
+ 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' year Nothing
Divisible _ r'@(Divisible _ _) -> findnextday r' afterday day
+ where
+ handlediv n r' getval mmax
+ | n > 0 && maybe True (n <=) mmax =
+ findnextdaywhere r' (divisible n . getval) afterday day
+ | otherwise = Nothing
findnextdaywhere r p afterday day
| maybe True p d = d
| otherwise = maybe d (findnextdaywhere r p True) d