From d0669f8402fee6eeb2f2f28409001848ced7a813 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 17 Jul 2008 19:08:35 -0400 Subject: 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). --- datetime.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'datetime.h') diff --git a/datetime.h b/datetime.h index b5dffba0..371cadbd 100644 --- a/datetime.h +++ b/datetime.h @@ -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); -- cgit v1.2.3