We now support having multiple sessions clocked in. These are paired by account name if given on the out entry, and otherwise an out closes the most recent in entry. Note that this breaks some backwards compatibility, in that we previously ignored the description on the clock out entry. To mitigate this, a new hidden flag --timeclock-old has been added, which reverts to the old behavior.
284 lines
6.5 KiB
Plaintext
284 lines
6.5 KiB
Plaintext
# * timeclock input
|
|
|
|
# ** 1. a timeclock session is parsed as a similarly-named transaction with one virtual posting.
|
|
<
|
|
i 2009/1/1 08:00:00
|
|
o 2009/1/1 09:00:00
|
|
|
|
i 2009/1/2 08:00:00 account name
|
|
o 2009/1/2 09:00:00
|
|
i 2009/1/3 08:00:00 some:account name and a description
|
|
o 2009/1/3 09:00:00
|
|
|
|
$ hledger -f timeclock:- print
|
|
>
|
|
2009-01-01 * 08:00-09:00
|
|
() 1.00h
|
|
|
|
2009-01-02 * 08:00-09:00
|
|
(account name) 1.00h
|
|
|
|
2009-01-03 * and a description
|
|
(some:account name) 1.00h
|
|
|
|
>=
|
|
|
|
# ** 2. Command-line account aliases are applied.
|
|
$ hledger -ftimeclock:- print --alias '/account/=FOO'
|
|
2009-01-01 * 08:00-09:00
|
|
() 1.00h
|
|
|
|
2009-01-02 * 08:00-09:00
|
|
(FOO name) 1.00h
|
|
|
|
2009-01-03 * and a description
|
|
(some:FOO name) 1.00h
|
|
|
|
>=
|
|
|
|
# ** 3. For a missing clock-out, now is implied
|
|
<
|
|
i 2020/1/1 08:00
|
|
$ hledger -f timeclock:- balance
|
|
> /./
|
|
>=
|
|
|
|
# ** 4. For a log not starting with clock-in, print error
|
|
<
|
|
o 2020/1/1 08:00
|
|
$ hledger -f timeclock:- balance
|
|
>2 /Could not find previous clockin to match this clockout./
|
|
>= !0
|
|
|
|
# ** 5. For two consecutive anonymous clock-ins, print error
|
|
<
|
|
i 2020/1/1 08:00
|
|
i 2020/1/1 09:00
|
|
$ hledger -f timeclock:- balance
|
|
>2 /Encountered clockin entry for session "" that is already active./
|
|
>= !0
|
|
|
|
# ** 6. Timeclock amounts are always rounded to two decimal places,
|
|
# even when displayed by print (#1527).
|
|
<
|
|
i 2020-01-30 08:38:35 acct
|
|
o 2020-01-30 09:03:35
|
|
$ hledger -f timeclock:- print
|
|
2020-01-30 * 08:38-09:03
|
|
(acct) 0.42h
|
|
|
|
>=
|
|
|
|
# ** 7. Comments and tags are supported. Double space is required between account name
|
|
# and description or comment. It is not required between description and comment.
|
|
<
|
|
i 2023-05-01 08:00:00 acct 1 description ; a comment with tag:
|
|
o 2023-05-01 09:00:00
|
|
i 2023-05-02 08:00:00 acct 2 ; another comment
|
|
o 2023-05-02 09:00:00
|
|
$ hledger -f timeclock:- print tag:tag
|
|
2023-05-01 * description ; a comment with tag:
|
|
(acct 1) 1.00h
|
|
|
|
>=
|
|
|
|
# ** 8.
|
|
$ hledger -f timeclock:- accounts
|
|
acct 1
|
|
acct 2
|
|
|
|
# ** 9. Support multiple sessions simultaneously clocked in.
|
|
<
|
|
i 2025-03-10 08:00:00 multi:1 description 1
|
|
i 2025-03-10 09:00:00 multi:2 description 2 ; note that these entries are both active
|
|
o 2025-03-10 12:00:00 multi:1
|
|
o 2025-03-10 15:00:00 multi:2
|
|
$ hledger -f timeclock:- print
|
|
>
|
|
2025-03-10 * description 1
|
|
(multi:1) 4.00h
|
|
|
|
2025-03-10 * description 2 ; note that these entries are both active
|
|
(multi:2) 6.00h
|
|
|
|
>=
|
|
|
|
# ** 10. Implicit clockouts apply to the correct session.
|
|
# The first 'o' here applies to multi:3, the next explicitly to multi:1, and the third to multi:2.
|
|
<
|
|
i 2025-03-10 08:00:00 multi:1 description 1
|
|
i 2025-03-10 09:00:00 multi:2 description 2
|
|
i 2025-03-10 10:00:00 multi:3 description 3
|
|
o 2025-03-10 11:00:00
|
|
o 2025-03-10 12:00:00 multi:1
|
|
o 2025-03-10 15:00:00
|
|
$ hledger -f timeclock:- print
|
|
>
|
|
2025-03-10 * description 1
|
|
(multi:1) 4.00h
|
|
|
|
2025-03-10 * description 2
|
|
(multi:2) 6.00h
|
|
|
|
2025-03-10 * description 3
|
|
(multi:3) 1.00h
|
|
|
|
>=
|
|
|
|
# ** 11. Multiple active sessions can span multiple days.
|
|
<
|
|
i 2025-03-11 19:00:00 multi:1
|
|
i 2025-03-11 20:00:00 multi:2
|
|
o 2025-03-12 08:00:00
|
|
o 2025-03-12 09:00:00
|
|
$ hledger -f timeclock:- print
|
|
>
|
|
2025-03-11 * 19:00-23:59
|
|
(multi:1) 5.00h
|
|
|
|
2025-03-11 * 20:00-23:59
|
|
(multi:2) 4.00h
|
|
|
|
2025-03-12 * 00:00-09:00
|
|
(multi:1) 9.00h
|
|
|
|
2025-03-12 * 00:00-08:00
|
|
(multi:2) 8.00h
|
|
|
|
>=
|
|
|
|
# ** 12. The --timeclock-old flag reverts to the old behavior.
|
|
<
|
|
i 2009/1/1 08:00:00
|
|
o 2009/1/1 09:00:00 stuff on checkout record is ignored
|
|
|
|
i 2009/1/2 08:00:00 account name
|
|
o 2009/1/2 09:00:00
|
|
i 2009/1/3 08:00:00 some:account name and a description
|
|
o 2009/1/3 09:00:00
|
|
|
|
$ hledger --timeclock-old -f timeclock:- print
|
|
>
|
|
2009-01-01 * 08:00-09:00
|
|
() 1.00h
|
|
|
|
2009-01-02 * 08:00-09:00
|
|
(account name) 1.00h
|
|
|
|
2009-01-03 * and a description
|
|
(some:account name) 1.00h
|
|
|
|
>=
|
|
|
|
## TODO
|
|
## multi-day sessions get a new transaction for each day
|
|
#hledger -ftimeclock:- print
|
|
#<<<
|
|
#i 2017/04/20 09:00:00 A
|
|
#o 2017/04/20 17:00:00
|
|
#i 2017/04/21 09:00:00 B
|
|
#o 2017/04/21 17:00:00
|
|
#i 2017/04/22 09:00:00 C
|
|
#o 2017/04/22 17:00:00
|
|
#>>>
|
|
#>>>2
|
|
#>>>=
|
|
#
|
|
## unclosed sessions are automatically closed at report time
|
|
## TODO this output looks wrong
|
|
#hledger -ftimeclock:- print
|
|
#<<<
|
|
#i 2017/04/20 09:00:00 A
|
|
#o 2017/04/20 17:00:00
|
|
#i 2017/04/21 09:00:00 B
|
|
#o 2017/04/21 17:00:00
|
|
#i 2017/04/22 09:00:00 C
|
|
#o 2017/04/22 17:00:00
|
|
#>>>
|
|
#2017-04-20 * 09:00-17:00
|
|
# (A) 8.00h
|
|
#
|
|
#2017-04-21 * 09:00-23:59
|
|
# (B) 15.00h
|
|
#
|
|
#2017-04-22 * 00:00-09:00
|
|
# (B) 9.00h
|
|
#
|
|
#2017-04-22 * 17:00-23:59
|
|
# () 7.00h
|
|
#
|
|
#2017-04-23 * 00:00-23:59
|
|
# () 24.00h
|
|
#
|
|
#2017-04-24 * 00:00-23:59
|
|
# () 24.00h
|
|
#
|
|
#2017-04-25 * 00:00-11:28
|
|
# () 11.47h
|
|
#
|
|
#>>>2
|
|
#>>>=
|
|
|
|
|
|
# ledger timeclock example from #ledger
|
|
# ==== consulting.timeclock
|
|
# ; Time log for consulting sideline
|
|
# ; All times UTC
|
|
# i 2011/01/26 16:00:00 XXXX:Remote "IPMI Access"
|
|
# o 2011/01/26 16:15:00
|
|
|
|
# i 2011/01/26 17:45:00 XXXX:Onsite "Fix opty server"
|
|
# o 2011/01/26 20:00:00
|
|
|
|
# i 2011/01/27 18:00:00 XXXX:Remote "SSL certificate for www.YYYY.com"
|
|
# o 2011/01/27 18:15:00
|
|
|
|
# ; vim:ts=2 sw=2 sts=2 et ft=ledger fdm=manual:
|
|
# ==== consulting.dat
|
|
# ; Ledger for Consulting sideline
|
|
|
|
# !account Consulting
|
|
# !include consulting.timeclock
|
|
# !end
|
|
|
|
|
|
# 2010/02/27 (INV#2) XXXX Test Invoice
|
|
# Consulting:XXXX:Remote -0.5h @ $75.00
|
|
# Consulting:XXXX:Onsite -2.25h @ $100.00
|
|
# Receivable:Consulting:XXXX
|
|
|
|
|
|
# ; vim:ts=2 sw=2 sts=2 et ft=ledger fdm=manual:
|
|
# ==== command: ledger -f consulting.dat -s bal
|
|
# -2.25h Consulting:XXXX:Onsite
|
|
# 2.25h Consulting:XXXX:Onsite "Fix opty server"
|
|
# -30.0m Consulting:XXXX:Remote
|
|
# 15.0m Consulting:XXXX:Remote "IPMI Access"
|
|
# 15.0m Consulting:XXXX:Remote "SSL certificate for www.YYYY.com"
|
|
# $262.5 Receivable:Consulting:XXXX
|
|
# --------------------
|
|
# $262.5
|
|
|
|
# # timezone-related tests
|
|
# # 1. as in ledger, historical prices may contain a time and timezone.
|
|
# # hledger ignores them and uses 00:00 local time instead.
|
|
# # XXX needs --value not --cost
|
|
# hledgerdev -f - balance --no-total --cost
|
|
# <<<
|
|
# P 2011/01/01 00:00:00 A $1
|
|
# P 2011/01/01 15:00:00-0100 A $2
|
|
|
|
# 2010/12/31
|
|
# (20101231) 1 A
|
|
|
|
# 2011/1/1
|
|
# (20110101) 1 A
|
|
|
|
# 2011/1/2
|
|
# (20110102) 1 A
|
|
# >>>
|
|
# 1 A 20101231
|
|
# $2 20110101
|
|
# $2 20110102
|
|
# >>>=0
|