pull code out of header
This commit is contained in:
@@ -14,6 +14,33 @@ void DateTime::Init()
|
|||||||
ZERO( *this );
|
ZERO( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DateTime::operator<( const DateTime& other ) const
|
||||||
|
{
|
||||||
|
#define COMPARE( v ) if(v<other.v) return true; if(v>other.v) return false;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DateTime::operator==( const DateTime& other ) const
|
||||||
|
{
|
||||||
|
#define COMPARE(x) if( x!=other.x ) return false;
|
||||||
|
COMPARE( tm_year );
|
||||||
|
COMPARE( tm_mon );
|
||||||
|
COMPARE( tm_mday );
|
||||||
|
COMPARE( tm_hour );
|
||||||
|
COMPARE( tm_min );
|
||||||
|
COMPARE( tm_sec );
|
||||||
|
#undef COMPARE
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DateTime DateTime::GetNowDateTime()
|
DateTime DateTime::GetNowDateTime()
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|||||||
@@ -41,31 +41,8 @@ struct DateTime
|
|||||||
DateTime();
|
DateTime();
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
bool operator<( const DateTime& other ) const
|
bool operator<( const DateTime& other ) const;
|
||||||
{
|
bool operator==( const DateTime& other ) const;
|
||||||
#define COMPARE( v ) if(v<other.v) return true; if(v>other.v) return false;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
bool operator==( const DateTime& other ) const
|
|
||||||
{
|
|
||||||
#define COMPARE(x) if( x!=other.x ) return false;
|
|
||||||
COMPARE( tm_year );
|
|
||||||
COMPARE( tm_mon );
|
|
||||||
COMPARE( tm_mday );
|
|
||||||
COMPARE( tm_hour );
|
|
||||||
COMPARE( tm_min );
|
|
||||||
COMPARE( tm_sec );
|
|
||||||
#undef COMPARE
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator!=( const DateTime& other ) const { return !operator==(other); }
|
bool operator!=( const DateTime& other ) const { return !operator==(other); }
|
||||||
|
|
||||||
static DateTime GetNowDateTime();
|
static DateTime GetNowDateTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user