summaryrefslogtreecommitdiff
path: root/config.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-08-05 22:37:29 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:17 -0400
commitb40006f450210351ef91b655b60f229e303be59a (patch)
treeeeb1828d3609fc578138ddd1aca314ef9e682e24 /config.cc
parented63481f3b1ff66f4ec2ef34f237002e33c0825c (diff)
downloadfork-ledger-b40006f450210351ef91b655b60f229e303be59a.tar.gz
fork-ledger-b40006f450210351ef91b655b60f229e303be59a.tar.bz2
fork-ledger-b40006f450210351ef91b655b60f229e303be59a.zip
Changed the --begin and --end switches to rely on interval parsing to
determine the beginning and ending of their range. Also, the ending is now inclusive.
Diffstat (limited to 'config.cc')
-rw-r--r--config.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/config.cc b/config.cc
index 7d82ab83..733cee69 100644
--- a/config.cc
+++ b/config.cc
@@ -615,18 +615,34 @@ OPT_BEGIN(account, "a:") {
// Report filtering
OPT_BEGIN(begin, "b:") {
+ char buf[128];
+ interval_t interval(optarg);
+ if (interval.begin)
+ std::strftime(buf, 127, formats[0], std::localtime(&interval.begin));
+ else
+ throw error(std::string("Could not determine beginning of period '") +
+ optarg + "'");
+
if (! config.predicate.empty())
config.predicate += "&";
config.predicate += "d>=[";
- config.predicate += optarg;
+ config.predicate += buf;
config.predicate += "]";
} OPT_END(begin);
OPT_BEGIN(end, "e:") {
+ char buf[128];
+ interval_t interval(optarg);
+ if (interval.end)
+ std::strftime(buf, 127, formats[0], std::localtime(&interval.end));
+ else
+ throw error(std::string("Could not determine end of period '") +
+ optarg + "'");
+
if (! config.predicate.empty())
config.predicate += "&";
config.predicate += "d<[";
- config.predicate += optarg;
+ config.predicate += buf;
config.predicate += "]";
} OPT_END(end);