diff options
Diffstat (limited to 'lib/Postdelay/TimeSpec.hs')
| -rw-r--r-- | lib/Postdelay/TimeSpec.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Postdelay/TimeSpec.hs b/lib/Postdelay/TimeSpec.hs index 384de4b..edd70c1 100644 --- a/lib/Postdelay/TimeSpec.hs +++ b/lib/Postdelay/TimeSpec.hs | |||
| @@ -56,13 +56,18 @@ timeSpec = label "Relative time specification" $ | |||
| 56 | ] | 56 | ] |
| 57 | 57 | ||
| 58 | toEndo :: [RWS LocalTime () LocalTime a] -> Endo LocalTime | 58 | toEndo :: [RWS LocalTime () LocalTime a] -> Endo LocalTime |
| 59 | toEndo acts = Endo $ \t -> fst $ execRWS (sequence acts) t t | 59 | toEndo (sequence -> act) = Endo $ \t -> fst $ execRWS act t t |
| 60 | 60 | ||
| 61 | timeOfDay, dateSpec :: StringParser s m => m (RWS LocalTime () LocalTime ()) | 61 | timeOfDay, dateSpec :: StringParser s m => m (RWS LocalTime () LocalTime ()) |
| 62 | timeOfDay = label "Time of day" $ shiftBack (1 % Day) . assign time <$> choice | 62 | timeOfDay = label "Time of day" $ shiftBack (1 % Day) . assign time <$> choice |
| 63 | [ TimeOfDay 0 0 0 <$ string' "midnight" | 63 | [ TimeOfDay 0 0 0 <$ string' "midnight" |
| 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 | ||
| 67 | h <- boundedNatural True $ 0 <=..<= 24 | ||
| 68 | m <- boundedNatural True $ 0 <=..<= 59 | ||
| 69 | s <- option 0 $ boundedRational True $ 0 <=..< 61 | ||
| 70 | return $ TimeOfDay h m s | ||
| 66 | ] | 71 | ] |
| 67 | dateSpec = label "Date" $ (date <~) <$> choice | 72 | dateSpec = label "Date" $ (date <~) <$> choice |
| 68 | [ view date <$ string' "today" | 73 | [ view date <$ string' "today" |
