mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.P.OrgMode: Also parse time in HHMM format
This commit is contained in:
parent
b627306772
commit
1c6ae39fc9
@ -116,6 +116,8 @@
|
|||||||
targeted refiling of the entered note into some existing tree of
|
targeted refiling of the entered note into some existing tree of
|
||||||
headings, respectively.
|
headings, respectively.
|
||||||
|
|
||||||
|
- Allowed the time specification in `HHMM` format.
|
||||||
|
|
||||||
### Other changes
|
### Other changes
|
||||||
|
|
||||||
## 0.17.1 (September 3, 2022)
|
## 0.17.1 (September 3, 2022)
|
||||||
|
@ -115,8 +115,8 @@ troubles. Weekdays always schedule into the future; e.g., if today is
|
|||||||
Monday and you schedule something for Monday, you will actually schedule
|
Monday and you schedule something for Monday, you will actually schedule
|
||||||
it for the /next/ Monday (the one in seven days).
|
it for the /next/ Monday (the one in seven days).
|
||||||
|
|
||||||
The time is specified in the @HH:MM@ format. The minutes may be
|
The time is specified in the @HH:MM@ or @HHMM@ format. The minutes may
|
||||||
omitted, in which case we assume a full hour is specified.
|
be omitted, in which case we assume a full hour is specified.
|
||||||
|
|
||||||
A few examples are probably in order. Suppose we have bound the key
|
A few examples are probably in order. Suppose we have bound the key
|
||||||
above, pressed it, and are now confronted with a prompt:
|
above, pressed it, and are now confronted with a prompt:
|
||||||
@ -532,13 +532,22 @@ pPriority = option NoPriority $
|
|||||||
-- | Try to parse a 'Time'.
|
-- | Try to parse a 'Time'.
|
||||||
pTimeOfDay :: Parser (Maybe TimeOfDay)
|
pTimeOfDay :: Parser (Maybe TimeOfDay)
|
||||||
pTimeOfDay = option Nothing $
|
pTimeOfDay = option Nothing $
|
||||||
skipSpaces *> choice
|
skipSpaces >> Just <$> choice
|
||||||
[ Just <$> (TimeOfDay <$> pHour <* ":" <*> pMinute) -- HH:MM
|
[ TimeOfDay <$> pHour <* ":" <*> pMinute -- HH:MM
|
||||||
, Just <$> (TimeOfDay <$> pHour <*> pure 0 ) -- HH
|
, pHHMM -- HHMM
|
||||||
|
, TimeOfDay <$> pHour <*> pure 0 -- HH
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
pMinute :: Parser Int = pNumBetween 0 59
|
pHHMM :: Parser TimeOfDay
|
||||||
|
pHHMM = do
|
||||||
|
let getTwo = count 2 (satisfy isDigit)
|
||||||
|
hh <- read <$> getTwo
|
||||||
|
guard (hh >= 0 && hh <= 23)
|
||||||
|
mm <- read <$> getTwo
|
||||||
|
guard (mm >= 0 && mm <= 59)
|
||||||
|
pure $ TimeOfDay hh mm
|
||||||
pHour :: Parser Int = pNumBetween 0 23
|
pHour :: Parser Int = pNumBetween 0 23
|
||||||
|
pMinute :: Parser Int = pNumBetween 0 59
|
||||||
|
|
||||||
-- | Parse a 'Date'.
|
-- | Parse a 'Date'.
|
||||||
pDate :: Parser Date
|
pDate :: Parser Date
|
||||||
|
@ -150,6 +150,7 @@ instance Arbitrary OrgMsg where
|
|||||||
hourGen :: Gen String
|
hourGen :: Gen String
|
||||||
hourGen = oneof
|
hourGen = oneof
|
||||||
[ pure " " <<>> (pad <$> hourInt) <<>> pure ":" <<>> (pad <$> minuteInt)
|
[ pure " " <<>> (pad <$> hourInt) <<>> pure ":" <<>> (pad <$> minuteInt)
|
||||||
|
, pure " " <<>> (pad <$> hourInt) <<>> (pad <$> minuteInt)
|
||||||
, pure ""
|
, pure ""
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
Loading…
x
Reference in New Issue
Block a user