diff options
author | John Wiegley <johnw@newartisans.com> | 2008-09-14 19:41:20 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-09-14 19:44:30 -0400 |
commit | 53c6e826f1e41f29c86f1c86f179f38838123d1d (patch) | |
tree | 99e9113d9089cda0b9978781681e4f2ba399ab7b /src | |
parent | 6d020a9b0ba2f20054de529f0183d23afdf32972 (diff) | |
download | fork-ledger-53c6e826f1e41f29c86f1c86f179f38838123d1d.tar.gz fork-ledger-53c6e826f1e41f29c86f1c86f179f38838123d1d.tar.bz2 fork-ledger-53c6e826f1e41f29c86f1c86f179f38838123d1d.zip |
Restored --format, --date-format (-y), and --input-date-format options.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cc | 5 | ||||
-rw-r--r-- | src/report.cc | 21 | ||||
-rw-r--r-- | src/report.h | 12 | ||||
-rw-r--r-- | src/times.h | 5 |
4 files changed, 31 insertions, 12 deletions
diff --git a/src/main.cc b/src/main.cc index d3dda002..a4e78ab7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -400,7 +400,10 @@ namespace ledger { if (verb == "register" || verb == "reg" || verb == "r") { verb = "register"; - command = reporter<>(new format_xacts(report, session.register_format)); + command = reporter<>(new format_xacts(report, + report.format_string.empty() ? + session.register_format : + report.format_string)); } else if (verb == "print" || verb == "p") { verb = "print"; diff --git a/src/report.cc b/src/report.cc index a894e036..db5dd04c 100644 --- a/src/report.cc +++ b/src/report.cc @@ -322,9 +322,9 @@ expr_t::ptr_op_t report_t::lookup(const string& name) case 'c': if (std::strcmp(p, "collapse") == 0) return MAKE_FUNCTOR(report_t::option_collapse); - else if (std::strcmp(p, "comm_as_payee") == 0) + else if (std::strcmp(p, "comm-as-payee") == 0) return MAKE_FUNCTOR(report_t::option_comm_as_payee); - else if (std::strcmp(p, "code_as_payee") == 0) + else if (std::strcmp(p, "code-as-payee") == 0) return MAKE_FUNCTOR(report_t::option_code_as_payee); break; @@ -333,6 +333,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::option_daily); else if (std::strcmp(p, "dow") == 0) return MAKE_FUNCTOR(report_t::option_dow); + else if (std::strcmp(p, "date-format_") == 0) + return MAKE_FUNCTOR(report_t::option_date_format_); break; case 'e': @@ -344,8 +346,7 @@ expr_t::ptr_op_t report_t::lookup(const string& name) break; case 'f': - if (std::strcmp(p, "F_") == 0 || - std::strcmp(p, "format_") == 0) + if (std::strcmp(p, "format_") == 0) return MAKE_FUNCTOR(report_t::option_format_); break; @@ -354,6 +355,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::option_head_); break; + case 'i': + if (std::strcmp(p, "input-date-format_") == 0) + return MAKE_FUNCTOR(report_t::option_input_date_format_); + break; + case 'j': if (! (*p + 1)) return MAKE_FUNCTOR(report_t::option_amount_data); @@ -430,6 +436,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) case 'y': if (std::strcmp(p, "yearly") == 0) return MAKE_FUNCTOR(report_t::option_yearly); + else if (std::strcmp(p, "y_") == 0) + return MAKE_FUNCTOR(report_t::option_date_format_); break; case 'E': @@ -437,6 +445,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::option_empty); break; + case 'F': + if (std::strcmp(p, "F_") == 0) + return MAKE_FUNCTOR(report_t::option_format_); + break; + case 'J': if (! (*p + 1)) return MAKE_FUNCTOR(report_t::option_total_data); diff --git a/src/report.h b/src/report.h index 03b80bc2..9c483c76 100644 --- a/src/report.h +++ b/src/report.h @@ -353,15 +353,17 @@ public: return true; } -#if 0 - value_t option_date_format(call_scope_t& args) { // y: - report->date_output_format = optarg; + value_t option_date_format_(call_scope_t& args) { // y: + ledger::output_date_format = args[0].as_string(); + return true; } - value_t option_input_date_format(call_scope_t& args) { // : - config->date_input_format = optarg; + value_t option_input_date_format_(call_scope_t& args) { // : + ledger::input_date_format = args[0].as_string(); + return true; } +#if 0 value_t option_balance_format(call_scope_t& args) { // : config->balance_format = optarg; } diff --git a/src/times.h b/src/times.h index 6abd2109..a7f905e6 100644 --- a/src/times.h +++ b/src/times.h @@ -89,10 +89,11 @@ inline string format_datetime(const datetime_t& when) inline string format_date(const date_t& when, const optional<string>& format = none) { - if (format) { + if (format || ! output_date_format.empty()) { char buf[256]; std::tm moment = gregorian::to_tm(when); - std::strftime(buf, 255, format->c_str(), &moment); + std::strftime(buf, 255, format ? + format->c_str() : output_date_format.c_str(), &moment); return buf; } else { return to_simple_string(when).substr(2); |