diff options
author | John Wiegley <johnw@newartisans.com> | 2008-08-02 00:37:36 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-08-02 00:37:36 -0400 |
commit | 5bf3f536b37e77b5dd663fffbd32e71b403d2c7a (patch) | |
tree | bb7a434cd8d04b5e67d278e44b2618b4a10efacc /main.cc | |
parent | 858978de8931ce5c98882472b10051f4e57dd029 (diff) | |
download | fork-ledger-5bf3f536b37e77b5dd663fffbd32e71b403d2c7a.tar.gz fork-ledger-5bf3f536b37e77b5dd663fffbd32e71b403d2c7a.tar.bz2 fork-ledger-5bf3f536b37e77b5dd663fffbd32e71b403d2c7a.zip |
Restored the interval_t time and added a new "period" debugging command.
You can use 'ledger period "daily in june"' to find out how Ledger will parse
that date string, plus up to the first 20 dates it encounters in the range.
Note that the 'end' displayed is currently exclusive.
Diffstat (limited to 'main.cc')
-rw-r--r-- | main.cc | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -222,6 +222,31 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], fmt.dump(*out); return 0; } + else if (verb == "period") { + interval_t interval(*arg); + + if (! is_valid(interval.begin)) { + *out << "Time period has no beginning." << std::endl; + } else { + *out << "begin: " << format_date(interval.begin) << std::endl; + *out << " end: " << format_date(interval.end) << std::endl; + *out << std::endl; + + date_t date = interval.first(); + + for (int i = 0; i < 20; i++) { + *out << std::right; + out->width(2); + + *out << i << ": " << format_date(date) << std::endl; + + date = interval.increment(date); + if (is_valid(interval.end) && date >= interval.end) + break; + } + } + return 0; + } // Parse the initialization file, which can only be textual; then // parse the journal data. |