summaryrefslogtreecommitdiff
path: root/datetime.h
diff options
context:
space:
mode:
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;