diff options
author | John Wiegley <johnw@newartisans.com> | 2004-09-10 18:38:52 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-09-10 18:38:52 -0400 |
commit | e1d6c4bff27f41fbe57738205ba3548554380a73 (patch) | |
tree | 270da6408bfdbbc10787e6ca1439aa715d7a6fbe /datetime.h | |
parent | e414123ecb472d1f86a2f1cfdbd2732144c20f0d (diff) | |
download | fork-ledger-e1d6c4bff27f41fbe57738205ba3548554380a73.tar.gz fork-ledger-e1d6c4bff27f41fbe57738205ba3548554380a73.tar.bz2 fork-ledger-e1d6c4bff27f41fbe57738205ba3548554380a73.zip |
interval_t objects now play nicely with python. see the bottom of main.py
Diffstat (limited to 'datetime.h')
-rw-r--r-- | datetime.h | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -4,18 +4,29 @@ #include "ledger.h" #include <ctime> +#include <sstream> namespace ledger { struct interval_t { - int years; - int months; - int seconds; - - interval_t(int _seconds = 0, int _months = 0, int _years = 0) - : years(_years), months(_months), seconds(_seconds) { + unsigned int years; + unsigned int months; + unsigned int seconds; + std::time_t begin; + std::time_t end; + + interval_t(int _seconds = 0, int _months = 0, int _years = 0, + 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() { @@ -27,11 +38,10 @@ struct interval_t return seconds > 0 || months > 0 || years > 0; } + std::time_t first(const std::time_t moment = 0); std::time_t increment(const std::time_t); - static interval_t parse(std::istream& in, - std::time_t * begin, - std::time_t * end); + void parse(std::istream& in); }; extern std::time_t now; |