diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-21 02:08:49 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-21 02:10:02 -0400 |
commit | a93111470d54e6345617b51fcc939f306854a524 (patch) | |
tree | 8a514e7f3d696ba6134907f7296c370c55a1811e /src/times.h | |
parent | 4ff8087815c9d93447ddb1651fa3ec8b82bba9be (diff) | |
download | fork-ledger-a93111470d54e6345617b51fcc939f306854a524.tar.gz fork-ledger-a93111470d54e6345617b51fcc939f306854a524.tar.bz2 fork-ledger-a93111470d54e6345617b51fcc939f306854a524.zip |
Greatly improved the way "weeks" are iterated
Diffstat (limited to 'src/times.h')
-rw-r--r-- | src/times.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/times.h b/src/times.h index 54c1dc80..8e0f72f9 100644 --- a/src/times.h +++ b/src/times.h @@ -70,8 +70,11 @@ inline bool is_valid(const date_t& moment) { #endif #define CURRENT_DATE() boost::gregorian::day_clock::universal_day() +extern int start_of_week; extern optional<std::string> input_date_format; +int string_to_day_of_week(const std::string& str); + datetime_t parse_datetime(const char * str, int current_year = -1); inline datetime_t parse_datetime(const std::string& str, int current_year = -1) { @@ -128,26 +131,32 @@ struct interval_t int years; int months; int days; + bool weekly; date_t begin; date_t end; - interval_t(int _days = 0, int _months = 0, int _years = 0, - const date_t& _begin = date_t(), - const date_t& _end = date_t()) + interval_t(int _days = 0, + int _months = 0, + int _years = 0, + bool _weekly = false, + const date_t& _begin = date_t(), + const date_t& _end = date_t()) : years(_years), months(_months), days(_days), - begin(_begin), end(_end) { - TRACE_CTOR(interval_t, "int, int, int, const date_t&, const date_t&"); + weekly(_weekly), begin(_begin), end(_end) { + TRACE_CTOR(interval_t, + "int, int, int, bool, const date_t&, const date_t&"); } interval_t(const interval_t& other) : years(other.years), months(other.months), days(other.days), + weekly(other.weekly), begin(other.begin), end(other.end) { TRACE_CTOR(interval_t, "copy"); } interval_t(const string& desc) - : years(0), months(0), days(0), begin(), end() { + : years(0), months(0), days(0), weekly(false), begin(), end() { TRACE_CTOR(interval_t, "const string&"); std::istringstream stream(desc); parse(stream); |