void VHTTPServerLog::_GetCurrentFormatedTime (XBOX::VString& outTimeString, bool inLocalTime)
{
	sWORD		year, month, day, hour, minute, seconds, milliseconds;
	XBOX::VTime	time;
	
	time.FromSystemTime();	// GMT time
	if (inLocalTime)
		time.GetLocalTime (year, month, day, hour, minute, seconds, milliseconds);
	else
		time.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);
	
	outTimeString.Clear();
	outTimeString.Printf ("%02d:%02d:%02d", hour, minute, seconds);
}
void VHTTPServerLog::_GetCurrentFormatedDate (XBOX::VString& outDateString, bool inLocalTime, const char inDateSeparator)
{
	sWORD		year, month, day, hour, minute, seconds, milliseconds;
	XBOX::VTime	time;
	
	time.FromSystemTime();	// GMT time
	if (inLocalTime)
		time.GetLocalTime (year, month, day, hour, minute, seconds, milliseconds);
	else
		time.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);
	
	outDateString.Clear();
	outDateString.Printf ("%04d%c%02d%c%02d %02d:%02d:%02d",	year, inDateSeparator,
																month, inDateSeparator, day,
																hour, minute, seconds);
}
예제 #3
0
BEGIN_TOOLBOX_NAMESPACE
USING_TOOLBOX_NAMESPACE


//--------------------------------------------------------------------------------------------------


static
void _GetRFC1123DateString (const XBOX::VTime& inDate, XBOX::VString& outString)
{
	sWORD year, month, day, hour, minute, second, millisecond;
	inDate.GetUTCTime (year, month, day, hour, minute, second, millisecond);

	outString.Clear();

	switch (inDate.GetWeekDay())
	{
	case 0:		outString.AppendCString ("Sun");	break;
	case 1:		outString.AppendCString ("Mon");	break;
	case 2:		outString.AppendCString ("Tue");	break;
	case 3:		outString.AppendCString ("Wed");	break;
	case 4:		outString.AppendCString ("Thu");	break;
	case 5:		outString.AppendCString ("Fri");	break;
	case 6:		outString.AppendCString ("Sat");	break;
	}

	outString.AppendPrintf (", %02d-", day);

	switch (month)
	{
	case 1:		outString.AppendCString ("Jan");	break;
	case 2:		outString.AppendCString ("Feb");	break;
	case 3:		outString.AppendCString ("Mar");	break;
	case 4:		outString.AppendCString ("Apr");	break;
	case 5:		outString.AppendCString ("May");	break;
	case 6:		outString.AppendCString ("Jun");	break;
	case 7:		outString.AppendCString ("Jul");	break;
	case 8:		outString.AppendCString ("Aug");	break;
	case 9:		outString.AppendCString ("Sep");	break;
	case 10:	outString.AppendCString ("Oct");	break;
	case 11:	outString.AppendCString ("Nov");	break;
	case 12:	outString.AppendCString ("Dec");	break;
	}

	outString.AppendPrintf ("-%04d %02d:%02d:%02d GMT", year, hour, minute, second);
}
void VHTTPServerLog::_MakeDateString (const XBOX::VTime& inTime, XBOX::VString& outDateString)
{
	/*	See description: http://httpd.apache.org/docs/2.2/logs.html#common

	[day/month/year:hour:minute:second zone]
	day = 2*digit
	month = 3*letter
	year = 4*digit
	hour = 2*digit
	minute = 2*digit
	second = 2*digit
	zone = (`+' | `-') 4*digit
	*/

	sWORD			year = 0, month = 0, day = 0, hour = 0, minute = 0, seconds = 0, milliseconds = 0;
	static sLONG	sGMTOffSet = 0;
	static bool		sGMTOffSetUndefined = true;

	inTime.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);

	if (sGMTOffSetUndefined)
	{
		sGMTOffSet = (XBOX::VSystem::GetGMTOffset (true) / (3600));
		sGMTOffSetUndefined = false;
	}

	outDateString.Clear();
	outDateString.Printf (	"%02d/%s/%04d:%02d:%02d:%02d %c%02ld00",
		day,
		CONST_ABBREVIATED_ENGLISH_MONTH_NAMES[month],
		year,
		hour,
		minute,
		seconds,
		(sGMTOffSet >= 0) ? '+' : '-',
		sGMTOffSet);
}