summaryrefslogtreecommitdiff
path: root/datetime.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-23 01:52:47 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-23 01:52:47 -0400
commite9f0dc8bb94c7590891a5c1dc0e1a431a2ed52a3 (patch)
tree39a1dbd35ec511cd72516da5f7184b22529cd198 /datetime.cc
parent61b007e58d49a8f2e38a6573d4c5fe6492570a2f (diff)
downloadfork-ledger-e9f0dc8bb94c7590891a5c1dc0e1a431a2ed52a3.tar.gz
fork-ledger-e9f0dc8bb94c7590891a5c1dc0e1a431a2ed52a3.tar.bz2
fork-ledger-e9f0dc8bb94c7590891a5c1dc0e1a431a2ed52a3.zip
fix to date mask parsing; put in a safety cutoffs when asserts are enabled
Diffstat (limited to 'datetime.cc')
-rw-r--r--datetime.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/datetime.cc b/datetime.cc
index 0d39d3b3..70b36279 100644
--- a/datetime.cc
+++ b/datetime.cc
@@ -47,8 +47,17 @@ std::time_t interval_t::first(const std::time_t moment)
}
std::time_t temp;
- while (std::difftime(moment, temp = increment(quant)) > 0)
+#if DEBUG_LEVEL >= RELEASE
+ int cutoff = 10000;
+#endif
+ while (std::difftime(moment, temp = increment(quant)) > 0) {
+ if (quant == temp)
+ break;
quant = temp;
+#if DEBUG_LEVEL >= RELEASE
+ assert(--cutoff > 0);
+#endif
+ }
}
return quant;
@@ -90,7 +99,8 @@ static void parse_inclusion_specifier(const std::string& word,
struct std::tm when;
if (! parse_date_mask(word.c_str(), &when))
- throw interval_expr_error("Could not parse 'in' date mask");
+ throw interval_expr_error(std::string("Could not parse date mask: ") +
+ word);
when.tm_hour = 0;
when.tm_min = 0;