timedot: allow minutes to be logged as Nm

This commit is contained in:
Simon Michael 2017-08-20 13:00:29 -07:00
parent bf79c7c5ac
commit 5cdb60b69b
5 changed files with 61 additions and 38 deletions

View File

@ -5,7 +5,9 @@ Example:
@ @
#DATE #DATE
#ACCT DOTS # Each dot represents 15m, spaces are ignored #ACCT DOTS # Each dot represents 15m, spaces are ignored
#ACCT 8 # numbers with or without a following h represent hours
#ACCT 5m # numbers followed by m represent minutes
# on 2/1, 1h was spent on FOSS haskell work, 0.25h on research, etc. # on 2/1, 1h was spent on FOSS haskell work, 0.25h on research, etc.
2/1 2/1
@ -126,16 +128,26 @@ timedotentryp = do
return t return t
timedotdurationp :: JournalParser m Quantity timedotdurationp :: JournalParser m Quantity
timedotdurationp = try timedotnumberp <|> timedotdotsp timedotdurationp = try timedotminutesp <|> try timedothoursp <|> timedotdotsp
-- | Parse a duration written as a decimal number of hours (optionally followed by the letter h). -- | Parse a duration written as a decimal number of minutes followed by the letter m.
-- @
-- 5m
-- @
timedotminutesp :: JournalParser m Quantity
timedotminutesp = do
(q, _, _, _) <- lift numberp
char 'm'
lift (many spacenonewline)
return $ q / 60
-- | Parse a duration written as a decimal number of hours optionally followed by the letter h.
-- @ -- @
-- 1.5h -- 1.5h
-- @ -- @
timedotnumberp :: JournalParser m Quantity timedothoursp :: JournalParser m Quantity
timedotnumberp = do timedothoursp = do
(q, _, _, _) <- lift numberp (q, _, _, _) <- lift numberp
lift (many spacenonewline)
optional $ char 'h' optional $ char 'h'
lift (many spacenonewline) lift (many spacenonewline)
return q return q

View File

@ -28,15 +28,19 @@ pairs, one per line.
Dates are hledger\-style simple dates (see hledger_journal(5)). Dates are hledger\-style simple dates (see hledger_journal(5)).
Categories are hledger\-style account names, optionally indented. Categories are hledger\-style account names, optionally indented.
There must be at least two spaces between the category and the quantity. There must be at least two spaces between the category and the quantity.
Quantities can be written in two ways: Quantities can be written in several ways:
.IP "1." 3 .IP "1." 3
a series of dots (period characters). a series of dots (.).
Each dot represents "a quarter" \- eg, a quarter hour. Each dot represents one quarter unit \- eg, a quarter hour.
Spaces can be used to group dots into hours, for easier counting. Spaces may optionally be used to group dots, for easier counting.
.IP "2." 3 .IP "2." 3
a number (integer or decimal), representing "units" \- eg, hours. an integral or decimal number optionally followed by the letter h
A good alternative when dots are cumbersome. represents whole units \- eg, hours.
(A number also can record negative quantities.) Numbers may be more convenient for large quantities (and can also record
negative quantities).
.IP "3." 3
an integral or decimal number followed by the letter m represents 1/60th
units \- eg, minutes.
.PP .PP
Blank lines and lines beginning with #, ; or * are ignored. Blank lines and lines beginning with #, ; or * are ignored.
An example: An example:

View File

@ -33,15 +33,18 @@ with a date, and is followed by category/quantity pairs, one per line.
Dates are hledger-style simple dates (see hledger_journal(5)). Dates are hledger-style simple dates (see hledger_journal(5)).
Categories are hledger-style account names, optionally indented. There Categories are hledger-style account names, optionally indented. There
must be at least two spaces between the category and the quantity. must be at least two spaces between the category and the quantity.
Quantities can be written in two ways: Quantities can be written in several ways:
1. a series of dots (period characters). Each dot represents "a 1. a series of dots (.). Each dot represents one quarter unit - eg, a
quarter" - eg, a quarter hour. Spaces can be used to group dots quarter hour. Spaces may optionally be used to group dots, for
into hours, for easier counting. easier counting.
2. a number (integer or decimal), representing "units" - eg, hours. A 2. an integral or decimal number optionally followed by the letter h
good alternative when dots are cumbersome. (A number also can represents whole units - eg, hours. Numbers may be more convenient
record negative quantities.) for large quantities (and can also record negative quantities).
3. an integral or decimal number followed by the letter m represents
1/60th units - eg, minutes.
Blank lines and lines beginning with #, ; or * are ignored. An Blank lines and lines beginning with #, ; or * are ignored. An
example: example:

View File

@ -31,15 +31,16 @@ A day entry begins with a date, and is followed by category/quantity pairs, one
Dates are hledger-style [simple dates](#simple-dates) (see hledger_journal(5)). Dates are hledger-style [simple dates](#simple-dates) (see hledger_journal(5)).
Categories are hledger-style account names, optionally indented. Categories are hledger-style account names, optionally indented.
There must be at least two spaces between the category and the quantity. There must be at least two spaces between the category and the quantity.
Quantities can be written in two ways: Quantities can be written in several ways:
1. a series of dots (period characters). 1. a series of dots (.).
Each dot represents "a quarter" - eg, a quarter hour. Each dot represents one quarter unit - eg, a quarter hour.
Spaces can be used to group dots into hours, for easier counting. Spaces may optionally be used to group dots, for easier counting.
2. a number (integer or decimal), representing "units" - eg, hours. 2. an integral or decimal number optionally followed by the letter h represents whole units - eg, hours.
A good alternative when dots are cumbersome. Numbers may be more convenient for large quantities (and can also record negative quantities).
(A number also can record negative quantities.)
3. an integral or decimal number followed by the letter m represents 1/60th units - eg, minutes.
Blank lines and lines beginning with #, ; or * are ignored. Blank lines and lines beginning with #, ; or * are ignored.
An example: An example:

View File

@ -25,17 +25,20 @@ FILE FORMAT
Dates are hledger-style simple dates (see hledger_journal(5)). Cate- Dates are hledger-style simple dates (see hledger_journal(5)). Cate-
gories are hledger-style account names, optionally indented. There gories are hledger-style account names, optionally indented. There
must be at least two spaces between the category and the quantity. must be at least two spaces between the category and the quantity.
Quantities can be written in two ways: Quantities can be written in several ways:
1. a series of dots (period characters). Each dot represents "a quar- 1. a series of dots (.). Each dot represents one quarter unit - eg, a
ter" - eg, a quarter hour. Spaces can be used to group dots into quarter hour. Spaces may optionally be used to group dots, for eas-
hours, for easier counting. ier counting.
2. a number (integer or decimal), representing "units" - eg, hours. A 2. an integral or decimal number optionally followed by the letter h
good alternative when dots are cumbersome. (A number also can represents whole units - eg, hours. Numbers may be more convenient
record negative quantities.) for large quantities (and can also record negative quantities).
Blank lines and lines beginning with #, ; or * are ignored. An exam- 3. an integral or decimal number followed by the letter m represents
1/60th units - eg, minutes.
Blank lines and lines beginning with #, ; or * are ignored. An exam-
ple: ple:
# on this day, 6h was spent on client work, 1.5h on haskell FOSS work, etc. # on this day, 6h was spent on client work, 1.5h on haskell FOSS work, etc.
@ -79,7 +82,7 @@ FILE FORMAT
------------++---------------------------------------- ------------++----------------------------------------
|| 7.75 2.25 8.00 || 7.75 2.25 8.00
I prefer to use period for separating account components. We can make I prefer to use period for separating account components. We can make
this work with an account alias: this work with an account alias:
2016/2/4 2016/2/4
@ -98,7 +101,7 @@ FILE FORMAT
REPORTING BUGS REPORTING BUGS
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
or hledger mail list) or hledger mail list)
@ -112,7 +115,7 @@ COPYRIGHT
SEE ALSO SEE ALSO
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1), hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time- hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
dot(5), ledger(1) dot(5), ledger(1)