summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <aethoago@141.li>2017-02-16 19:13:32 +0100
committerGregor Kleen <aethoago@141.li>2017-02-16 19:13:32 +0100
commit3dc71afee7b4efc214e159176e380182ac5141dd (patch)
treebb2247daeec5ad9d4e98f055d4693ab8dd7745c3
parent4343e02ca8431e61e2dc1755d1288dd6c55c9a23 (diff)
downloadpostdelay-3dc71afee7b4efc214e159176e380182ac5141dd.tar
postdelay-3dc71afee7b4efc214e159176e380182ac5141dd.tar.gz
postdelay-3dc71afee7b4efc214e159176e380182ac5141dd.tar.bz2
postdelay-3dc71afee7b4efc214e159176e380182ac5141dd.tar.xz
postdelay-3dc71afee7b4efc214e159176e380182ac5141dd.zip
Time specifications
-rw-r--r--lib/Postdelay/TimeSpec.hs19
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
72dateSpec = label "Date" $ (date <~) <$> choice 85dateSpec = 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"