diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Postdelay/TimeSpec.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Postdelay/TimeSpec.hs b/lib/Postdelay/TimeSpec.hs index edd70c1..f84a196 100644 --- a/lib/Postdelay/TimeSpec.hs +++ b/lib/Postdelay/TimeSpec.hs | |||
@@ -64,11 +64,24 @@ timeOfDay = label "Time of day" $ shiftBack (1 % Day) . assign time <$> choice | |||
64 | , TimeOfDay 12 0 0 <$ string' "noon" | 64 | , TimeOfDay 12 0 0 <$ string' "noon" |
65 | , TimeOfDay 16 0 0 <$ string' "teatime" | 65 | , TimeOfDay 16 0 0 <$ string' "teatime" |
66 | , try $ do | 66 | , try $ do |
67 | h <- boundedNatural True $ 0 <=..<= 24 | 67 | h <- hour24 True |
68 | m <- boundedNatural True $ 0 <=..<= 59 | 68 | m <- minute True |
69 | s <- option 0 $ boundedRational True $ 0 <=..< 61 | 69 | s <- option 0 $ second True |
70 | return $ TimeOfDay h m s | 70 | return $ TimeOfDay h m s |
71 | , try $ do | ||
72 | h <- hour12 False | ||
73 | m <- option 0 $ char ':' *> minute False | ||
74 | s <- option 0 $ char ':' *> second False | ||
75 | spaceConsumer | ||
76 | amPm <- (0 <$ string' "am") <|> (12 <$ string' "pm") | ||
77 | return $ TimeOfDay (h + amPm) m s | ||
71 | ] | 78 | ] |
79 | where | ||
80 | hour12 pad = label "Modulus 12 hour" . fmap (flip mod 12) . boundedNatural pad $ 1 <=..<= 12 | ||
81 | hour24 pad = label "Modulus 24 hour" . boundedNatural pad $ 0 <=..< 24 | ||
82 | minute pad = label "Minute" . boundedNatural pad $ 0 <=..< 60 | ||
83 | second pad = label "Second" . boundedRational pad $ 0 <=..< 61 | ||
84 | |||
72 | dateSpec = label "Date" $ (date <~) <$> choice | 85 | dateSpec = label "Date" $ (date <~) <$> choice |
73 | [ view date <$ string' "today" | 86 | [ view date <$ string' "today" |
74 | , views date succ <$ string' "tomorrow" | 87 | , views date succ <$ string' "tomorrow" |