From 4165a2a20536dcc6efa66aaadf89d89d8e2f33ed Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sat, 15 Jan 2011 16:18:33 -0500 Subject: [PATCH] More consistency with operators. Unsure about <= and >= here: don't know if "this" is enough. --- src/DateTime.cpp | 14 ++++++++++++++ src/DateTime.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/DateTime.cpp b/src/DateTime.cpp index 02eb91f636..ba69d02f03 100644 --- a/src/DateTime.cpp +++ b/src/DateTime.cpp @@ -42,6 +42,20 @@ bool DateTime::operator==( const DateTime& other ) const return true; } +bool DateTime::operator>( const DateTime& other ) const +{ +#define COMPARE( v ) if(v!=other.v) return v>other.v; + COMPARE( tm_year ); + COMPARE( tm_mon ); + COMPARE( tm_mday ); + COMPARE( tm_hour ); + COMPARE( tm_min ); + COMPARE( tm_sec ); +#undef COMPARE + // they're equal + return false; +} + DateTime DateTime::GetNowDateTime() { time_t now = time(NULL); diff --git a/src/DateTime.h b/src/DateTime.h index c0d0fac6d6..3fa1735bd0 100644 --- a/src/DateTime.h +++ b/src/DateTime.h @@ -45,6 +45,7 @@ struct DateTime void Init(); bool operator<( const DateTime& other ) const; + bool operator>( const DateTime& other ) const; bool operator==( const DateTime& other ) const; bool operator!=( const DateTime& other ) const { return !operator==(other); }