fix handling of schedled time of 12 PM
This commit is contained in:
parent
e7ac51c0fe
commit
6d8906a995
1 changed files with 7 additions and 4 deletions
|
@ -275,13 +275,16 @@ toScheduledTime "any time" = Just AnyTime
|
||||||
toScheduledTime v = case words v of
|
toScheduledTime v = case words v of
|
||||||
(s:ampm:[])
|
(s:ampm:[])
|
||||||
| map toUpper ampm == "AM" ->
|
| map toUpper ampm == "AM" ->
|
||||||
go s (\h -> if h == 12 then 0 else h)
|
go s h0
|
||||||
| map toUpper ampm == "PM" ->
|
| map toUpper ampm == "PM" ->
|
||||||
go s (+ 12)
|
go s (\h -> (h0 h) + 12)
|
||||||
| otherwise -> Nothing
|
| otherwise -> Nothing
|
||||||
(s:[]) -> go s id
|
(s:[]) -> go s id
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
|
h0 h
|
||||||
|
| h == 12 = 0
|
||||||
|
| otherwise = h
|
||||||
go :: String -> (Int -> Int) -> Maybe ScheduledTime
|
go :: String -> (Int -> Int) -> Maybe ScheduledTime
|
||||||
go s adjust =
|
go s adjust =
|
||||||
let (h, m) = separate (== ':') s
|
let (h, m) = separate (== ':') s
|
||||||
|
@ -318,8 +321,8 @@ instance Arbitrary ScheduledTime where
|
||||||
arbitrary = oneof
|
arbitrary = oneof
|
||||||
[ pure AnyTime
|
[ pure AnyTime
|
||||||
, SpecificTime
|
, SpecificTime
|
||||||
<$> nonNegative arbitrary
|
<$> nonNegative arbitrary `suchThat` (<= 23)
|
||||||
<*> nonNegative arbitrary
|
<*> nonNegative arbitrary `suchThat` (<= 59)
|
||||||
]
|
]
|
||||||
|
|
||||||
instance Arbitrary Recurrance where
|
instance Arbitrary Recurrance where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue