本文整理汇总了C++中TTime::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ TTime::Parse方法的具体用法?C++ TTime::Parse怎么用?C++ TTime::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTime
的用法示例。
在下文中一共展示了TTime::Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseFromXMLTimeString
// ---------------------------------------------------------------------------
// TPresCondValidity::ParseFromXMLTimeString()
// ---------------------------------------------------------------------------
//
TInt TPresCondValidity::ParseFromXMLTimeString(const TDesC& aXMLTimeString,
TTime& aUTCDateTime)
{
OPENG_DP(D_OPENG_LIT( " TPresCondValidity::ParseFromXMLTimeString()" ) );
OPENG_DP(D_OPENG_LIT( " ParseFromXMLTimeString aXMLTimeString = %S"),
&aXMLTimeString);
TInt err(KErrNone);
// Initializing the locale
TLocale myLocale, systemLocale;
myLocale.Refresh();
systemLocale.Refresh();
myLocale.SetDateFormat(EDateJapanese);
myLocale.SetDateSeparator('-',1);
myLocale.SetDateSeparator('-',2);
myLocale.SetDateSeparator('T',3);
myLocale.SetTimeFormat(ETime24);
myLocale.SetTimeSeparator(':',1);
myLocale.SetTimeSeparator(':',2);
myLocale.SetTimeSeparator(' ',3);
myLocale.Set();
TTime myTime;
TTime myUTCtime;
TChar uTCtimeSign(aXMLTimeString[23]); // 23 is ascii T
// parsing main time
TBuf<KPresDateTimeBufLength> dateTimeBuffer(aXMLTimeString);
dateTimeBuffer.Delete(KPresDTWithoutUTCLength-1,6);
dateTimeBuffer.Replace(KPresDTSeperatorPos,1,KPresSpaceString);
myTime.Parse(dateTimeBuffer);
// parsing utc time
TBuf<KPresDateTimeBufLength> uTCbuffer(aXMLTimeString);
uTCbuffer.Delete(0,KPresDTWithoutUTCLength);
myUTCtime.Parse(uTCbuffer);
TDateTime uTCDateTime = myUTCtime.DateTime();
// adding or substracting utc from main time
if(uTCtimeSign=='+') // if diff is positive
{
aUTCDateTime = myTime - TTimeIntervalHours(uTCDateTime.Hour());
aUTCDateTime = aUTCDateTime - TTimeIntervalMinutes(uTCDateTime.Minute());
}
else if(uTCtimeSign=='-')
{
aUTCDateTime = myTime + TTimeIntervalHours(uTCDateTime.Hour());
aUTCDateTime = aUTCDateTime + TTimeIntervalMinutes(uTCDateTime.Minute());
}
else
err = KErrArgument;
// putting the system locale back
systemLocale.Set();
return err;
}