Beispiel #1
0
cGameDate::cGameDate()
{
	setDefaultDate();
}
Beispiel #2
0
 void PropertyImpl::setDefault(const SDODate d )
 {
     setDefaultDate(d);
 }
Beispiel #3
0
void cGameDate::fromString( const std::string& arg, eDateFormat format )
{
	LOGICAL success = false;

	if( !arg.empty() )
	{
		UI32 start = 0;
		UI32 index = arg.find_first_of( dateSeparator );

		switch( format )
		{
			case YMD:
				if( index == start + 4 )
				{
					setYear( (UI16) str2num( const_cast<char*>( arg.substr( start, 4 ).c_str() ) ) );
					start = index + 1;
					index = arg.find_first_of( dateSeparator, start );
					if( index == start + 2 )
					{
						setMonth( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
						start = index + 1;
						index = arg.find_first_of( dateTimeSeparator, start );
						if( index == start + 2 )
						{
							setDay( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
							start = index + 1;
							index = arg.find_first_of( timeSeparator, start );
							if( index == start + 2 )
							{
								setHour( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
								start = index + 1;
								setMinute( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
								success = true;
							}
						}
					}
				}
				break;
			case DMY:
				if( index == start + 2 )
				{
					setDay( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
					start = index + 1;
					index = arg.find_first_of( dateSeparator, start );
					if( index == start + 2 )
					{
						setMonth( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
						start = index + 1;
						index = arg.find_first_of( dateTimeSeparator, start );
						if( index == start + 4 )
						{
							setYear( (UI16) str2num( const_cast<char*>( arg.substr( start, 4 ).c_str() ) ) );
							start = index + 1;
							index = arg.find_first_of( timeSeparator, start );
							if( index == start + 2 )
							{
								setHour( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
								start = index + 1;
								setMinute( (UI08) str2num( const_cast<char*>( arg.substr( start, 2 ).c_str() ) ) );
								success = true;
							}
						}
					}
				}
				break;
		}
	}

	if( !success )
		setDefaultDate();
}