diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-17 19:08:35 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-17 20:55:11 -0400 |
commit | d0669f8402fee6eeb2f2f28409001848ced7a813 (patch) | |
tree | 2336988e52aea8b373ef36c3b34f213be018fadf /datetime.h | |
parent | ed0deb95c22e52c20b29a243b7c3c4db363fc67c (diff) | |
download | fork-ledger-d0669f8402fee6eeb2f2f28409001848ced7a813.tar.gz fork-ledger-d0669f8402fee6eeb2f2f28409001848ced7a813.tar.bz2 fork-ledger-d0669f8402fee6eeb2f2f28409001848ced7a813.zip |
Removed implicit conversions from ledger::date_t to std::time_t, since this
operator was never been chosen over operator bool (and hence, all times
appeared as either 0 or 1).
Diffstat (limited to 'datetime.h')
-rw-r--r-- | datetime.h | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -96,9 +96,6 @@ class date_t operator bool() const { return when != 0; } - operator std::time_t() { - return when; - } operator std::string() const { return to_string(); } @@ -225,13 +222,13 @@ class datetime_t : public date_t int sec() const { return localtime()->tm_sec; } -}; -inline long operator-(const datetime_t& left, const datetime_t& right) { - std::time_t left_time(left); - std::time_t right_time(right); - return left_time - right_time; -} + friend inline long operator-(const datetime_t& left, const datetime_t& right) { + std::time_t left_time = left.when; + std::time_t right_time = right.when; + return long(left_time) - long(right_time); + } +}; inline datetime_t operator+(const datetime_t& left, const long seconds) { datetime_t temp(left); |