aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-01 11:44:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-01 11:44:00 -0400
commita95227e3e32ffa155e1ac9f294d72ef6e111cdd2 (patch)
treee2da5d791ba55ea6c81b2925fe1ff28acef734cc
parent4b1de9c2c913820c4fc729ebd4638b30fa91b630 (diff)
fix handling of schedled time of 12 PM
-rw-r--r--Utility/Scheduled.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs
index 6401cfa20..9cc2ab1ac 100644
--- a/Utility/Scheduled.hs
+++ b/Utility/Scheduled.hs
@@ -275,13 +275,16 @@ toScheduledTime "any time" = Just AnyTime
toScheduledTime v = case words v of
(s:ampm:[])
| map toUpper ampm == "AM" ->
- go s (\h -> if h == 12 then 0 else h)
+ go s h0
| map toUpper ampm == "PM" ->
- go s (+ 12)
+ go s (\h -> (h0 h) + 12)
| otherwise -> Nothing
(s:[]) -> go s id
_ -> Nothing
where
+ h0 h
+ | h == 12 = 0
+ | otherwise = h
go :: String -> (Int -> Int) -> Maybe ScheduledTime
go s adjust =
let (h, m) = separate (== ':') s
@@ -318,8 +321,8 @@ instance Arbitrary ScheduledTime where
arbitrary = oneof
[ pure AnyTime
, SpecificTime
- <$> nonNegative arbitrary
- <*> nonNegative arbitrary
+ <$> nonNegative arbitrary `suchThat` (<= 23)
+ <*> nonNegative arbitrary `suchThat` (<= 59)
]
instance Arbitrary Recurrance where