More consistency with operators.

Unsure about <= and >= here: don't know if "this" is enough.
This commit is contained in:
Jason Felds
2011-01-15 16:18:33 -05:00
parent b0036aeabc
commit 4165a2a205
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -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);
+1
View File
@@ -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); }