More consistency with operators.
Unsure about <= and >= here: don't know if "this" is enough.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user