diff options
author | Martin Michlmayr <tbm@cyrius.com> | 2014-05-30 23:46:20 -0400 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2014-05-30 23:52:36 -0400 |
commit | a5ffcc42ff2d6f6d06141b5098337f4bc092d2e0 (patch) | |
tree | d3c79eb8cbc5dbb853acce381374efc207d1089d | |
parent | 53b8aa8802a590f0139355fa0a4e3857f39d9836 (diff) | |
download | fork-ledger-a5ffcc42ff2d6f6d06141b5098337f4bc092d2e0.tar.gz fork-ledger-a5ffcc42ff2d6f6d06141b5098337f4bc092d2e0.tar.bz2 fork-ledger-a5ffcc42ff2d6f6d06141b5098337f4bc092d2e0.zip |
Improve backwards compatibility with ledger2
This brings some single character format strings in line with what
they actually meant in ledger2.
Bug fix for #755
-rw-r--r-- | doc/ledger3.texi | 6 | ||||
-rw-r--r-- | src/format.cc | 11 | ||||
-rw-r--r-- | test/regress/755.test | 90 | ||||
-rw-r--r-- | test/regress/C19E4E9B.test | 2 |
4 files changed, 99 insertions, 10 deletions
diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 2dc1a021..d4df63ec 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -8072,10 +8072,8 @@ file. @item e Inserts the ending line of that transaction within the file. -@c @item D By default, this is the same as @code{%[%Y/%m%/d]}. The date -@c format used can be changed at any time with the @option{--date-format -@c @var{DATE_FORMAT} (-y)} flag, however. Using @code{%D} gives the -@c user more control over the way dates are output. +@item D +Returns the date according to the default format. @item d Returns the date according to the default format. If the transaction diff --git a/src/format.cc b/src/format.cc index 302c28d6..402cfdfd 100644 --- a/src/format.cc +++ b/src/format.cc @@ -74,17 +74,18 @@ namespace { char letter; const char * expr; } single_letter_mappings[] = { - { 'd', "date" }, + { 'd', "aux_date ? format_date(date) + \"=\" + format_date(aux_date) : format_date(date)" }, + { 'D', "date" }, { 'S', "filename" }, { 'B', "beg_pos" }, { 'b', "beg_line" }, { 'E', "end_pos" }, { 'e', "end_line" }, - { 'X', "cleared" }, - { 'Y', "xact.cleared" }, - { 'C', "code" }, + { 'X', "\"* \" if cleared" }, + { 'Y', "\"* \" if xact.cleared" }, + { 'C', "\"(\" + code + \") \" if code" }, { 'P', "payee" }, - { 'a', "account.name" }, + { 'a', "account" }, { 'A', "account" }, { 't', "justify(scrub(display_amount), $min, $max, $left, color)" }, { 'T', "justify(scrub(display_total), $min, $max, $left, color)" }, diff --git a/test/regress/755.test b/test/regress/755.test new file mode 100644 index 00000000..9581debc --- /dev/null +++ b/test/regress/755.test @@ -0,0 +1,90 @@ + +; Test backwards compatibility with ledger2 + +--date-format %Y/%m/%d + +2009-04-17 * Test 1 + A 10.00 EUR + B + +2009-04-18=2010-04-20 (110) Test 2 + * C 20.00 EUR ;foo + * B + +test -F "%a\n" reg +A +B +C +B +end test + +test -F "%A\n" reg +A +B +C +B +end test + +test -F "%d\n" reg +2009/04/17 +2009/04/17 +2009/04/18=2010/04/20 +2009/04/18=2010/04/20 +end test + +test -F "%D\n" reg +2009/04/17 +2009/04/17 +2009/04/18 +2009/04/18 +end test + +test -F "%S\n" reg +$FILE +$FILE +$FILE +$FILE +end test + +test -F "%b\n" reg +7 +8 +11 +12 +end test + +test -F "%B\n" reg +90 +126 +168 +209 +end test + +test -F "%X%P\n" reg +* Test 1 +* Test 1 +* Test 2 +* Test 2 +end test + +test -F "%Y%P\n" reg +* Test 1 +* Test 1 +Test 2 +Test 2 +end test + +test -F "%C%P\n" reg +Test 1 +Test 1 +(110) Test 2 +(110) Test 2 +end test + +test -F "%N\n" reg + + +foo + +end test + diff --git a/test/regress/C19E4E9B.test b/test/regress/C19E4E9B.test index 4837b4cd..822e3f0e 100644 --- a/test/regress/C19E4E9B.test +++ b/test/regress/C19E4E9B.test @@ -6,7 +6,7 @@ A 1 AAA @ 2.00 EUR B -2.00 EUR -test reg --format "%S: %d %P %t %T\n" +test reg --format "%S: %D %P %t %T\n" $FILE: 2012/01/01 Buy AAA 1 AAA 1 AAA $FILE: 2012/01/01 Buy AAA -1.00 EUR 1 AAA -1.00 EUR |