diff --git a/stepmania/src/DateTime.cpp b/stepmania/src/DateTime.cpp index eebb7d9eb0..13c76c0d38 100644 --- a/stepmania/src/DateTime.cpp +++ b/stepmania/src/DateTime.cpp @@ -3,6 +3,16 @@ #include "RageUtil.h" +DateTime::DateTime() +{ + Init(); +} + +void DateTime::Init() +{ + ZERO( *this ); +} + DateTime DateTime::GetNowDateTime() { time_t now = time(NULL); @@ -30,28 +40,29 @@ void DateTime::StripTime() // CString DateTime::GetString() const { - return ssprintf( "%d-%02d-%02d %02d:%02d:%02d", - tm_year+1900, - tm_mon+1, - tm_mday, - tm_hour, - tm_min, - tm_sec ); -} - -CString DateTime::GetDateString() const -{ - return ssprintf( "%d-%02d-%02d", + CString s = ssprintf( "%d-%02d-%02d", tm_year+1900, tm_mon+1, tm_mday ); + + if( tm_hour != 0 || + tm_min != 0 || + tm_sec != 0 ) + { + s += ssprintf( " %02d:%02d:%02d", + tm_hour, + tm_min, + tm_sec ); + } + + return s; } bool DateTime::FromString( const CString sDateTime ) { - int ret; + Init(); - ZERO( *this ); + int ret; ret = sscanf( sDateTime, "%d-%d-%d %d:%d:%d", &tm_year, diff --git a/stepmania/src/DateTime.h b/stepmania/src/DateTime.h index 1a0083d736..0f9bea78cb 100644 --- a/stepmania/src/DateTime.h +++ b/stepmania/src/DateTime.h @@ -27,6 +27,9 @@ tm GetDayInYearAndYear( int iDayInYearIndex, int iYear ); struct DateTime : public tm { + DateTime(); + void Init(); + bool operator<( const DateTime& other ) const { #define COMPARE( v ) if(v!=other.v) return v