summaryrefslogtreecommitdiff
path: root/datetime.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-10 18:38:52 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-10 18:38:52 -0400
commite1d6c4bff27f41fbe57738205ba3548554380a73 (patch)
tree270da6408bfdbbc10787e6ca1439aa715d7a6fbe /datetime.h
parente414123ecb472d1f86a2f1cfdbd2732144c20f0d (diff)
downloadfork-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.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/datetime.h b/datetime.h
index a3b0651a..51483172 100644
--- a/datetime.h
+++ b/datetime.h
@@ -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;