imp: add "since" as a synonym of "from" in period expressions (ledger compat)

This commit is contained in:
Simon Michael 2022-12-22 02:12:25 -10:00
parent 85e9fbcf7d
commit e2ddf1e685
2 changed files with 5 additions and 3 deletions

View File

@ -904,6 +904,8 @@ weekdaysp = fmap head . group . sort <$> sepBy1 weekday (string' ",")
-- Right (DayOfYear 11 29,DateSpan 2009-01-01..)
-- >>> p "every 11/29 from 2009"
-- Right (DayOfYear 11 29,DateSpan 2009-01-01..)
-- >>> p "every 11/29 since 2009"
-- Right (DayOfYear 11 29,DateSpan 2009-01-01..)
-- >>> p "every 2nd Thursday of month to 2009"
-- Right (WeekdayOfMonth 2 4,DateSpan ..2008-12-31)
-- >>> p "every 1st monday of month to 2009"
@ -1004,7 +1006,7 @@ periodexprdatespanp rdate = choice $ map try [
-- Right DateSpan 2017
doubledatespanp :: Day -> TextParser m DateSpan
doubledatespanp rdate = liftA2 fromToSpan
(optional (string' "from" *> skipNonNewlineSpaces) *> smartdate)
(optional ((string' "from" <|> string' "since") *> skipNonNewlineSpaces) *> smartdate)
(skipNonNewlineSpaces *> choice [string' "to", string "..", string "-"]
*> skipNonNewlineSpaces *> smartdate)
where
@ -1027,7 +1029,7 @@ quarterdatespanp rdate = do
fromdatespanp :: Day -> TextParser m DateSpan
fromdatespanp rdate = fromSpan <$> choice
[ string' "from" *> skipNonNewlineSpaces *> smartdate
[ (string' "from" <|> string' "since") *> skipNonNewlineSpaces *> smartdate
, smartdate <* choice [string "..", string "-"]
]
where

View File

@ -4362,7 +4362,7 @@ earliest or latest transaction in your journal:
| | |
|----------------------|-----------------------------------|
| `-p "from 2009/1/1"` | everything after january 1, 2009 |
| `-p "from 2009/1"` | the same |
| `-p "since 2009/1"` | the same, since is a synonym |
| `-p "from 2009"` | the same |
| `-p "to 2009"` | everything before january 1, 2009 |