summaryrefslogtreecommitdiff
path: root/walk.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-12 23:21:57 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-12 23:21:57 -0400
commita4f5abe860025c8f4120b3bfb7aea7e555692153 (patch)
tree852b5a0ff6936b940520b6b3124a3c538b8e4771 /walk.cc
parentb20ddba1d5652157bb432e0c826ea746dd81482e (diff)
downloadfork-ledger-a4f5abe860025c8f4120b3bfb7aea7e555692153.tar.gz
fork-ledger-a4f5abe860025c8f4120b3bfb7aea7e555692153.tar.bz2
fork-ledger-a4f5abe860025c8f4120b3bfb7aea7e555692153.zip
Added a days-of-the-week report, under -w
Diffstat (limited to 'walk.cc')
-rw-r--r--walk.cc35
1 files changed, 26 insertions, 9 deletions
diff --git a/walk.cc b/walk.cc
index b0769ed6..a13ba06c 100644
--- a/walk.cc
+++ b/walk.cc
@@ -117,19 +117,24 @@ void changed_value_transactions::operator()(transaction_t * xact)
last_xact = xact;
}
-void subtotal_transactions::flush()
+void subtotal_transactions::flush(const char * spec_fmt)
{
- entry_t * entry = new entry_t;
-
char buf[256];
- std::string fmt = "- ";
- fmt += format_t::date_format;
- // Make sure the end date is inclusive
- if (start != finish)
- finish -= 86400;
+ if (! spec_fmt) {
+ std::string fmt = "- ";
+ fmt += format_t::date_format;
+
+ // Make sure the end date is inclusive
+ if (start != finish)
+ finish -= 86400;
+
+ std::strftime(buf, 255, fmt.c_str(), std::gmtime(&finish));
+ } else {
+ std::strftime(buf, 255, spec_fmt, std::gmtime(&finish));
+ }
- std::strftime(buf, 255, fmt.c_str(), std::gmtime(&finish));
+ entry_t * entry = new entry_t;
entry->payee = buf;
entry_temps.push_back(entry);
@@ -211,4 +216,16 @@ void interval_transactions::operator()(transaction_t * xact)
last_xact = xact;
}
+void dow_transactions::flush()
+{
+ for (int i = 0; i < 7; i++) {
+ for (transactions_deque::iterator d = days_of_the_week[i].begin();
+ d != days_of_the_week[i].end();
+ d++)
+ subtotal_transactions::operator()(*d);
+ subtotal_transactions::flush("%As");
+ days_of_the_week[i].clear();
+ }
+}
+
} // namespace ledger