summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-13 15:56:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-13 15:56:07 -0400
commita0865e6c494ec4bdfb7ab058a5633a8634d48bd4 (patch)
tree8cdf7c97d98f7592b7b211fdba10c2a85fb6eb21 /Utility
parentd6bf4460d8b7ff91ba553958240054ca8a2a91d6 (diff)
improve calculation of nextTime for AnyTime events
Allow AnyTime events that still have time to occur in the current day to fall in a window covering the current day, instead of waiting until the next day in the Recurrance.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Scheduled.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index 5b667d285..e759ecef4 100644
--- a/Utility/Scheduled.hs
+++ b/Utility/Scheduled.hs
@@ -76,19 +76,19 @@ nextTime schedule lasttime = do
calcNextTime :: Schedule -> Maybe LocalTime -> LocalTime -> Maybe NextTime
calcNextTime (Schedule recurrance scheduledtime) lasttime currenttime
| scheduledtime == AnyTime = do
- start <- findfromtoday
+ start <- findfromtoday True
return $ NextTimeWindow
start
(LocalTime (localDay start) (TimeOfDay 23 59 0))
- | otherwise = NextTimeExactly <$> findfromtoday
+ | otherwise = NextTimeExactly <$> findfromtoday False
where
- findfromtoday =
+ findfromtoday anytime =
LocalTime <$> nextday <*> pure nexttime
where
nextday = findnextday recurrance afterday today
today = localDay currenttime
afterday = sameaslastday || toolatetoday
- toolatetoday = localTimeOfDay currenttime >= nexttime
+ toolatetoday = not anytime && localTimeOfDay currenttime >= nexttime
sameaslastday = (localDay <$> lasttime) == Just today
nexttime = case scheduledtime of
AnyTime -> TimeOfDay 0 0 0