hledger-0.5: A ledger-compatible text-based accounting tool.Source codeContentsIndex
Ledger.Dates
Description

For date and time values, we use the standard Day and UTCTime types.

A SmartDate is a date which may be partially-specified or relative. Eg 20081231, but also 200812, 1231, tomorrow, last week, next year. We represent these as a triple of strings like ("2008","12",""), ("","","tomorrow"), ("","last","week").

A 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.)

An Interval is ledger's reporting interval - weekly, monthly, quarterly, etc.

Synopsis
showDate :: Day -> String
getCurrentDay :: IO Day
elapsedSeconds :: Fractional a => UTCTime -> UTCTime -> a
splitSpan :: Interval -> DateSpan -> [DateSpan]
parsePeriodExpr :: Day -> String -> (Interval, DateSpan)
spanFromSmartDateString :: Day -> String -> DateSpan
spanFromSmartDate :: Day -> SmartDate -> DateSpan
fixSmartDateStr :: Day -> String -> String
fixSmartDate :: Day -> SmartDate -> Day
prevday :: Day -> Day
parsedatetimeM :: String -> Maybe LocalTime
parsedatetime :: String -> LocalTime
parsedateM :: String -> Maybe Day
parsedate :: String -> Day
parsetimewith :: ParseTime t => String -> String -> t -> t
smartdate :: GenParser Char st SmartDate
yyyymmdd :: GenParser Char st SmartDate
ymd :: GenParser Char st SmartDate
ym :: GenParser Char st SmartDate
y :: GenParser Char st SmartDate
d :: GenParser Char st SmartDate
md :: GenParser Char st SmartDate
month :: GenParser Char st SmartDate
mon :: GenParser Char st SmartDate
yesterday :: GenParser Char st SmartDate
tomorrow :: GenParser Char st SmartDate
today :: GenParser Char st SmartDate
lastthisnextthing :: GenParser Char st SmartDate
periodexpr :: Day -> GenParser Char st (Interval, DateSpan)
intervalanddateperiodexpr :: Day -> GenParser Char st (Interval, DateSpan)
intervalperiodexpr :: GenParser Char st (Interval, DateSpan)
dateperiodexpr :: Day -> GenParser Char st (Interval, DateSpan)
periodexprinterval :: GenParser Char st Interval
periodexprdatespan :: Day -> GenParser Char st DateSpan
doubledatespan :: Day -> GenParser Char st DateSpan
fromdatespan :: Day -> GenParser Char st DateSpan
todatespan :: Day -> GenParser Char st DateSpan
justdatespan :: Day -> GenParser Char st DateSpan
Documentation
showDate :: Day -> StringSource
getCurrentDay :: IO DaySource
elapsedSeconds :: Fractional a => UTCTime -> UTCTime -> aSource
splitSpan :: Interval -> DateSpan -> [DateSpan]Source
Split a DateSpan into one or more consecutive spans at the specified interval.
parsePeriodExpr :: Day -> String -> (Interval, DateSpan)Source
Parse a period expression to an Interval and overall DateSpan using the provided reference date.
spanFromSmartDateString :: Day -> String -> DateSpanSource
Convert a single smart date string to a date span using the provided reference date.
spanFromSmartDate :: Day -> SmartDate -> DateSpanSource
fixSmartDateStr :: Day -> String -> StringSource
Convert a smart date string to an explicit yyyymmdd string using the provided reference date.
fixSmartDate :: Day -> SmartDate -> DaySource
Convert a SmartDate to an absolute date using the provided reference date.
prevday :: Day -> DaySource
parsedatetimeM :: String -> Maybe LocalTimeSource
parsedatetime :: String -> LocalTimeSource
Parse a date-time string to a time type, or raise an error.
parsedateM :: String -> Maybe DaySource
Parse a date string to a time type, or raise an error.
parsedate :: String -> DaySource
Parse a date string to a time type, or raise an error.
parsetimewith :: ParseTime t => String -> String -> t -> tSource
Parse a time string to a time type using the provided pattern, or return the default.
smartdate :: GenParser Char st SmartDateSource

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
 (not yet) 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.

yyyymmdd :: GenParser Char st SmartDateSource
ymd :: GenParser Char st SmartDateSource
ym :: GenParser Char st SmartDateSource
y :: GenParser Char st SmartDateSource
d :: GenParser Char st SmartDateSource
md :: GenParser Char st SmartDateSource
month :: GenParser Char st SmartDateSource
mon :: GenParser Char st SmartDateSource
yesterday :: GenParser Char st SmartDateSource
tomorrow :: GenParser Char st SmartDateSource
today :: GenParser Char st SmartDateSource
lastthisnextthing :: GenParser Char st SmartDateSource
periodexpr :: Day -> GenParser Char st (Interval, DateSpan)Source
intervalanddateperiodexpr :: Day -> GenParser Char st (Interval, DateSpan)Source
intervalperiodexpr :: GenParser Char st (Interval, DateSpan)Source
dateperiodexpr :: Day -> GenParser Char st (Interval, DateSpan)Source
periodexprinterval :: GenParser Char st IntervalSource
periodexprdatespan :: Day -> GenParser Char st DateSpanSource
doubledatespan :: Day -> GenParser Char st DateSpanSource
fromdatespan :: Day -> GenParser Char st DateSpanSource
todatespan :: Day -> GenParser Char st DateSpanSource
justdatespan :: Day -> GenParser Char st DateSpanSource
Produced by Haddock version 2.7.2