summaryrefslogtreecommitdiff
path: root/datetime.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-17 19:08:35 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-17 20:55:11 -0400
commitd0669f8402fee6eeb2f2f28409001848ced7a813 (patch)
tree2336988e52aea8b373ef36c3b34f213be018fadf /datetime.h
parented0deb95c22e52c20b29a243b7c3c4db363fc67c (diff)
downloadfork-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.h15
1 files changed, 6 insertions, 9 deletions
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);