From 26c19c65b0cf7d3e93579f395a8d59b6c6512637 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 28 Feb 2020 01:33:11 -0800 Subject: [PATCH] timedot: allow a note after the date, use as transaction descriptions --- hledger-lib/Hledger/Read/TimedotReader.hs | 6 ++++-- hledger-lib/hledger_timedot.m4.md | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Read/TimedotReader.hs b/hledger-lib/Hledger/Read/TimedotReader.hs index d7c12dcf5..de8924a7f 100644 --- a/hledger-lib/Hledger/Read/TimedotReader.hs +++ b/hledger-lib/Hledger/Read/TimedotReader.hs @@ -53,6 +53,7 @@ import Data.Char (isSpace) import Data.List (foldl') import Data.Maybe import Data.Text (Text) +import qualified Data.Text as T import Text.Megaparsec hiding (parse) import Text.Megaparsec.Char @@ -115,10 +116,11 @@ timedotdayp :: JournalParser m [Transaction] timedotdayp = do traceparse " timedotdayp" lift $ optional orgheadingprefixp - d <- datep <* lift eolof + d <- datep + daydesc <- strip <$> lift restofline es <- catMaybes <$> many (const Nothing <$> try (lift emptyorcommentlinep') <|> Just <$> (notFollowedBy datep >> timedotentryp)) - return $ map (\t -> t{tdate=d}) es -- <$> many timedotentryp + return $ map (\t -> t{tdate=d, tdescription=T.pack daydesc}) es -- <$> many timedotentryp -- | Parse a single timedot entry to one (dateless) transaction. -- @ diff --git a/hledger-lib/hledger_timedot.m4.md b/hledger-lib/hledger_timedot.m4.md index fff56bf44..9b84d3c0f 100644 --- a/hledger-lib/hledger_timedot.m4.md +++ b/hledger-lib/hledger_timedot.m4.md @@ -22,11 +22,14 @@ so it could be used to represent dated quantities other than time. In the docs below we'll assume it's time. A timedot file contains a series of day entries. -A day entry begins with a non-indented hledger-style [simple date](journal.html#simple-dates) (see hledger_journal(5)). +A day entry begins with a non-indented hledger-style +[simple date](journal.html#simple-dates) (Y-M-D, Y/M/D, Y.M.D..) +Any additional text on the same line is used as a transaction description for this day. This is followed by optionally-indented timelog items for that day, one per line. Each timelog item is a note, usually a hledger:style:account:name representing a time category, followed by two or more spaces, and a quantity. +Each timelog item generates a hledger transaction. Quantities can be written as: