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
#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.
2/1
@ -126,16 +128,26 @@ timedotentryp = do
return t
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
-- @
timedotnumberp :: JournalParser m Quantity
timedotnumberp = do
timedothoursp :: JournalParser m Quantity
timedothoursp = do
(q, _, _, _) <- lift numberp
lift (many spacenonewline)
optional $ char 'h'
lift (many spacenonewline)
return q

View File

@ -28,15 +28,19 @@ pairs, one per line.
Dates are hledger\-style simple dates (see hledger_journal(5)).
Categories are hledger\-style account names, optionally indented.
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
a series of dots (period characters).
Each dot represents "a quarter" \- eg, a quarter hour.
Spaces can be used to group dots into hours, for easier counting.
a series of dots (.).
Each dot represents one quarter unit \- eg, a quarter hour.
Spaces may optionally be used to group dots, for easier counting.
.IP "2." 3
a number (integer or decimal), representing "units" \- eg, hours.
A good alternative when dots are cumbersome.
(A number also can record negative quantities.)
an integral or decimal number optionally followed by the letter h
represents whole units \- eg, hours.
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
Blank lines and lines beginning with #, ; or * are ignored.
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)).
Categories are hledger-style account names, optionally indented. 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). Each dot represents "a
quarter" - eg, a quarter hour. Spaces can be used to group dots
into hours, for easier counting.
1. a series of dots (.). Each dot represents one quarter unit - eg, a
quarter hour. Spaces may optionally be used to group dots, for
easier counting.
2. a number (integer or decimal), representing "units" - eg, hours. A
good alternative when dots are cumbersome. (A number also can
record negative quantities.)
2. an integral or decimal number optionally followed by the letter h
represents whole units - eg, hours. Numbers may be more convenient
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
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)).
Categories are hledger-style account names, optionally indented.
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).
Each dot represents "a quarter" - eg, a quarter hour.
Spaces can be used to group dots into hours, for easier counting.
1. a series of dots (.).
Each dot represents one quarter unit - eg, a quarter hour.
Spaces may optionally be used to group dots, for easier counting.
2. a number (integer or decimal), representing "units" - eg, hours.
A good alternative when dots are cumbersome.
(A number also can record negative quantities.)
2. an integral or decimal number optionally followed by the letter h represents whole units - eg, hours.
Numbers may be more convenient 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 example:

View File

@ -25,17 +25,20 @@ FILE FORMAT
Dates are hledger-style simple dates (see hledger_journal(5)). Cate-
gories are hledger-style account names, optionally indented. 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). Each dot represents "a quar-
ter" - eg, a quarter hour. Spaces can be used to group dots into
hours, for easier counting.
1. a series of dots (.). Each dot represents one quarter unit - eg, a
quarter hour. Spaces may optionally be used to group dots, for eas-
ier counting.
2. a number (integer or decimal), representing "units" - eg, hours. A
good alternative when dots are cumbersome. (A number also can
record negative quantities.)
2. an integral or decimal number optionally followed by the letter h
represents whole units - eg, hours. Numbers may be more convenient
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:
# 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
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:
2016/2/4
@ -98,7 +101,7 @@ FILE FORMAT
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)
@ -112,7 +115,7 @@ COPYRIGHT
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-
dot(5), ledger(1)