mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 03:42:25 +03:00
;lib: add YYYY.MM.DD to parsedate/parsedateM helpers
For a bit more consistency with simple dates. And document better.
This commit is contained in:
parent
5a2f28f3ac
commit
43c55bf4ea
@ -668,11 +668,14 @@ parsetime =
|
||||
#endif
|
||||
|
||||
|
||||
-- | Parse a couple of date string formats to a time type.
|
||||
-- | Try to parse a couple of date string formats:
|
||||
-- `YYYY-MM-DD`, `YYYY/MM/DD` or `YYYY.MM.DD`, with leading zeros required.
|
||||
-- For internal use, not quite the same as the journal's "simple dates".
|
||||
parsedateM :: String -> Maybe Day
|
||||
parsedateM s = firstJust [
|
||||
parsetime defaultTimeLocale "%Y/%m/%d" s,
|
||||
parsetime defaultTimeLocale "%Y-%m-%d" s
|
||||
parsetime defaultTimeLocale "%Y-%m-%d" s,
|
||||
parsetime defaultTimeLocale "%Y.%m.%d" s
|
||||
]
|
||||
|
||||
|
||||
@ -681,7 +684,7 @@ parsedateM s = firstJust [
|
||||
-- parsedatetime s = fromMaybe (error' $ "could not parse timestamp \"" ++ s ++ "\"")
|
||||
-- (parsedatetimeM s)
|
||||
|
||||
-- | Parse a YYYY-MM-DD or YYYY/MM/DD date string to a Day, or raise an error. For testing/debugging.
|
||||
-- | Like parsedateM, raising an error on parse failure.
|
||||
--
|
||||
-- >>> parsedate "2008/02/03"
|
||||
-- 2008-02-03
|
||||
|
Loading…
Reference in New Issue
Block a user