Date arithmetic

39 views
Skip to first unread message

Marcin Owsiany

unread,
Jan 16, 2020, 3:50:51 AM1/16/20
to Ledger
Hello,

I'm trying to use ledger (among other things) to keep track of when my bank deposits end.

Example transaction:
2019-12-05 ! x
 
Deposit  7 EUR
 
; duration:: 30d
 
Cash


This seems to work as expected:

ledger -f t.ledger --limit "account =~ /Deposit/" --format "date:          %(format_date(date))\ndate+duration: %(format_date(date + tag('duration')))" register
date
:          19-Dec-05
date
+duration: 20-Jan-04


But changing the duration to 1 month yields strange results:

2019-12-05 ! x
 
Deposit  7 EUR
 
; duration:: 1m
 
Cash


ledger -f t.ledger --limit "account =~ /Deposit/" --format "date:          %(format_date(date))\ndate+duration: %(format_date(date + tag('duration')))" register
date
:          19-Dec-05

date
+duration: 20-Feb-03


What's going on? Is 1m not what I think it is?

I failed to find how duration values are parsed in documentation and in source code. Can someone please point me at the relevant place in either?

Marcin
Reply all
Reply to author
Forward
0 new messages