static
void GetFormatedDateTimeString (const XBOX::VTime& inTime, XBOX::VString &outDateTimeString)
{
	sLONG8 ms = inTime.GetMilliseconds() - (inTime.GetJulianDay() * 24 * 60 * 60 * 1000);

	outDateTimeString.Clear();
	outDateTimeString.Printf ("D%04d%02d%02dT%08d",
		inTime.GetLocalYear(),
		inTime.GetLocalMonth(),
		inTime.GetLocalDay(),
		ms);
}
/*
 *	Set the Time part of a XBOX::VTime (does NOT touch Date)
 */
static
void SetTimeValue (XBOX::VTime& ioTime, sLONG inDayHour)
{
	sLONG8 timeMilliseconds = 0;

	ioTime.SetLocalHour (0);
	ioTime.SetLocalMinute (0);
	ioTime.SetLocalSecond (0);
	ioTime.SetLocalMillisecond (0);

	timeMilliseconds = ioTime.GetMilliseconds();
	timeMilliseconds += (inDayHour * 1000);
	ioTime.FromMilliseconds (timeMilliseconds);
}
Exemplo n.º 3
0
void VHTTPCookie::FromString (const XBOX::VString& inString)
{
	XBOX::VectorOfVString	stringValues;
	XBOX::VString			string;
	XBOX::VString			nameString;
	XBOX::VString			valueString;

	Clear();

	inString.GetSubStrings (CHAR_SEMICOLON, stringValues, false, true);

	for (VectorOfVString::iterator it = stringValues.begin(); it != stringValues.end(); ++it)
	{
		sLONG pos = 0;
		string.FromString (*it);

		if ((pos = HTTPTools::FindASCIICString (string, "secure")) == 1)
		{
			SetSecure (true);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "httpOnly")) == 1)
		{
			SetHttpOnly (true);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "version")) == 1)
		{
			SetVersion (1);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "max-age")) == 1)
		{
			HTTPTools::ExtractFieldNameValue (string, nameString, valueString);
			fMaxAge = valueString.GetLong();
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "expires")) == 1)
		{
			XBOX::VTime curTime;
			XBOX::VTime expiresTime;
			XBOX::VTime::Now (curTime);

			HTTPTools::ExtractFieldNameValue (string, nameString, valueString);
			expiresTime.FromRfc822String (valueString);

			if (expiresTime.GetMilliseconds() > curTime.GetMilliseconds())
				fMaxAge = (expiresTime.GetMilliseconds() - curTime.GetMilliseconds()) / 1000;
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "path")) == 1)
		{
			HTTPTools::ExtractFieldNameValue (string, nameString, fPath);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "domain")) == 1)
		{
			HTTPTools::ExtractFieldNameValue (string, nameString, fDomain);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "comment")) == 1)
		{
			HTTPTools::ExtractFieldNameValue (string, nameString, fComment);
		}
		else if ((pos = HTTPTools::FindASCIICString (string, "=")))
		{
			HTTPTools::ExtractFieldNameValue (string, fName, fValue);
		}
	}
}