diff options
author | John Wiegley <johnw@newartisans.com> | 2006-03-03 09:45:44 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:28 -0400 |
commit | 96d6d62ad94082ca777c2c88b88e0346a5d00e65 (patch) | |
tree | b50a26a9c4c0cc0ab90b1772cc75368739501fa5 /datetime.h | |
parent | 7d3e45958e805f8acaf399ef14d53757979240ab (diff) | |
download | fork-ledger-96d6d62ad94082ca777c2c88b88e0346a5d00e65.tar.gz fork-ledger-96d6d62ad94082ca777c2c88b88e0346a5d00e65.tar.bz2 fork-ledger-96d6d62ad94082ca777c2c88b88e0346a5d00e65.zip |
Began support for improved commodity handling.
Diffstat (limited to 'datetime.h')
-rw-r--r-- | datetime.h | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -1,13 +1,9 @@ #ifndef _DATETIME_H #define _DATETIME_H -#include "debug.h" - #include <ctime> #include <sstream> -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 |