From 96d6d62ad94082ca777c2c88b88e0346a5d00e65 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 3 Mar 2006 09:45:44 +0000 Subject: Began support for improved commodity handling. --- datetime.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'datetime.h') diff --git a/datetime.h b/datetime.h index 78054ec2..fb3751bf 100644 --- a/datetime.h +++ b/datetime.h @@ -1,13 +1,9 @@ #ifndef _DATETIME_H #define _DATETIME_H -#include "debug.h" - #include #include -namespace ledger { - struct interval_t { unsigned int years; @@ -20,19 +16,12 @@ struct interval_t std::time_t _begin = 0, std::time_t _end = 0) : years(_years), months(_months), seconds(_seconds), begin(_begin), end(_end) { - DEBUG_PRINT("ledger.memory.ctors", "ctor interval_t"); } interval_t(const std::string& desc) : years(0), months(0), seconds(0), begin(0), end(0) { - DEBUG_PRINT("ledger.memory.ctors", "ctor interval_t"); std::istringstream stream(desc); parse(stream); } -#ifdef DEBUG_ENABLED - ~interval_t() { - DEBUG_PRINT("ledger.memory.dtors", "dtor interval_t"); - } -#endif operator bool() const { return seconds > 0 || months > 0 || years > 0; @@ -57,6 +46,15 @@ bool parse_date(const char * date_str, std::time_t * result, const int year = -1); bool quick_parse_date(const char * date_str, std::time_t * result); -} // namespace ledger +class datetime_error : public std::exception { + std::string reason; + public: + datetime_error(const std::string& _reason) throw() : reason(_reason) {} + virtual ~datetime_error() throw() {} + + virtual const char* what() const throw() { + return reason.c_str(); + } +}; #endif // _DATETIME_H -- cgit v1.2.3