Date parsing and utilities for hledger.
For date and time values, we use the standard Day and UTCTime types.
SmartDate is a date which may be partially-specified or relative.
Eg 2008/12/31, but also 2008/12, 12/31, tomorrow, last week, next year.
We represent these as a triple of strings like ("2008","12",""),
DateSpan is the span of time between two specific calendar dates, or
an open-ended span where one or both dates are unspecified. (A date span
with both ends unspecified matches all dates.)
Interval is ledger's "reporting interval" - weekly, monthly,
- getCurrentDay :: IO Day
- getCurrentMonth :: IO Int
- getCurrentYear :: IO Integer
- nulldate :: Day
- spanContainsDate :: DateSpan -> Day -> Bool
- parsedateM :: String -> Maybe Day
- parsedate :: String -> Day
- showDate :: Day -> String
- showDateSpan :: DateSpan -> [Char]
- elapsedSeconds :: Fractional a => UTCTime -> UTCTime -> a
- prevday :: Day -> Day
- parsePeriodExpr :: Day -> String -> Either ParseError (Interval, DateSpan)
- nulldatespan :: DateSpan
- tests_Hledger_Data_Dates :: Test
- failIfInvalidYear :: Monad m => String -> m ()
- datesepchar :: ParsecT [Char] u Identity Char
- datesepchars :: [Char]
- spanStart :: DateSpan -> Maybe Day
- spanEnd :: DateSpan -> Maybe Day
- spansSpan :: [DateSpan] -> DateSpan
- spanIntersect :: DateSpan -> DateSpan -> DateSpan
- spansIntersect :: [DateSpan] -> DateSpan
- spanUnion :: DateSpan -> DateSpan -> DateSpan
- spansUnion :: [DateSpan] -> DateSpan
- orDatesFrom :: DateSpan -> DateSpan -> DateSpan
- smartdate :: GenParser Char st SmartDate
- splitSpan :: Interval -> DateSpan -> [DateSpan]
- fixSmartDate :: Day -> SmartDate -> Day
- fixSmartDateStr :: Day -> String -> String
- fixSmartDateStrEither :: Day -> String -> Either ParseError String
- fixSmartDateStrEither' :: Day -> String -> Either ParseError Day
- daysInSpan :: DateSpan -> Maybe Integer
- maybePeriod :: Day -> String -> Maybe (Interval, DateSpan)
- mkdatespan :: String -> String -> DateSpan
Misc date handling utilities
Parse a period expression to an Interval and overall DateSpan using the provided reference date, or return a parse error.
Get overall span enclosing multiple sequentially ordered spans.
Combine two datespans, filling any unspecified dates in the first with dates from the second. Not a clip operation, just uses the second's start/end dates as defaults when the first does not specify them.
Parse a date in any of the formats allowed in ledger's period expressions, and maybe some others:
2004 2004/10 2004/10/1 10/1 21 october, oct yesterday, today, tomorrow this/next/last week/day/month/quarter/year
Returns a SmartDate, to be converted to a full date later (see fixSmartDate). Assumes any text in the parse stream has been lowercased.
Split a DateSpan into one or more consecutive spans at the specified interval.
Convert a SmartDate to an absolute date using the provided reference date.
Convert a smart date string to an explicit yyyy/mm/dd string using the provided reference date, or raise an error.
A safe version of fixSmartDateStr.
Count the days in a DateSpan, or if it is open-ended return Nothing.