simplify
This commit is contained in:
+25
-14
@@ -3,6 +3,16 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
DateTime::DateTime()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DateTime::Init()
|
||||||
|
{
|
||||||
|
ZERO( *this );
|
||||||
|
}
|
||||||
|
|
||||||
DateTime DateTime::GetNowDateTime()
|
DateTime DateTime::GetNowDateTime()
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
@@ -30,28 +40,29 @@ void DateTime::StripTime()
|
|||||||
//
|
//
|
||||||
CString DateTime::GetString() const
|
CString DateTime::GetString() const
|
||||||
{
|
{
|
||||||
return ssprintf( "%d-%02d-%02d %02d:%02d:%02d",
|
CString s = ssprintf( "%d-%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",
|
|
||||||
tm_year+1900,
|
tm_year+1900,
|
||||||
tm_mon+1,
|
tm_mon+1,
|
||||||
tm_mday );
|
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 )
|
bool DateTime::FromString( const CString sDateTime )
|
||||||
{
|
{
|
||||||
int ret;
|
Init();
|
||||||
|
|
||||||
ZERO( *this );
|
int ret;
|
||||||
|
|
||||||
ret = sscanf( sDateTime, "%d-%d-%d %d:%d:%d",
|
ret = sscanf( sDateTime, "%d-%d-%d %d:%d:%d",
|
||||||
&tm_year,
|
&tm_year,
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ tm GetDayInYearAndYear( int iDayInYearIndex, int iYear );
|
|||||||
|
|
||||||
struct DateTime : public tm
|
struct DateTime : public tm
|
||||||
{
|
{
|
||||||
|
DateTime();
|
||||||
|
void Init();
|
||||||
|
|
||||||
bool operator<( const DateTime& other ) const
|
bool operator<( const DateTime& other ) const
|
||||||
{
|
{
|
||||||
#define COMPARE( v ) if(v!=other.v) return v<other.v;
|
#define COMPARE( v ) if(v!=other.v) return v<other.v;
|
||||||
@@ -46,7 +49,6 @@ struct DateTime : public tm
|
|||||||
void StripTime();
|
void StripTime();
|
||||||
|
|
||||||
CString GetString() const;
|
CString GetString() const;
|
||||||
CString GetDateString() const;
|
|
||||||
bool FromString( const CString sDateTime );
|
bool FromString( const CString sDateTime );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user