当前位置: 首页>>代码示例>>C++>>正文


C++ TDateTime::SetYear方法代码示例

本文整理汇总了C++中TDateTime::SetYear方法的典型用法代码示例。如果您正苦于以下问题:C++ TDateTime::SetYear方法的具体用法?C++ TDateTime::SetYear怎么用?C++ TDateTime::SetYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDateTime的用法示例。


在下文中一共展示了TDateTime::SetYear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetRulesL

void CTzDbStdTimeAlignment::GetRulesL(CTzRules& aRules, const TDateTime& aStartDateTime, TDateTime& aEndDateTime)
	{
	// get the ruleSet for this time alignment
	CTzDbRuleSet* ruleSet = iReadOnlyTzDb.GetRuleSetL(iPersistedEntity.iOffsetToRuleSet);
	if (ruleSet)
		{
		CleanupStack::PushL(ruleSet); // PUSH #1 - RULESET

		// get end time of time alignment
		TTime endTime;
		CalculateEndTime(endTime);
		if (endTime == Time::MaxTTime())
			{
			aEndDateTime.SetYear(KMaxTUint16);
			}
		else
			{
			aEndDateTime = endTime.DateTime();
			}
	
		TInt firstYearOfInterest = (aRules.StartYear() >= aStartDateTime.Year()) ? aRules.StartYear() : aStartDateTime.Year();
		TInt lastYearOfInterest  = (aRules.EndYear() <= aEndDateTime.Year()) ? aRules.EndYear() : aEndDateTime.Year();
		CTzRules* newRules = CTzRules::NewL(firstYearOfInterest, lastYearOfInterest);
		CleanupStack::PushL(newRules); // PUSH #2 - NEWRULES
		
		ruleSet->GetRulesL(*newRules,iPersistedEntity.iUtcOffset,aStartDateTime,aEndDateTime);
		
		// the new rules obtained for the current std time alignment must be merged into 
		// the global rule collection
		AddRulesToCollectionL(aRules,*newRules);
	
		CleanupStack::PopAndDestroy(2, ruleSet); // POP #2,#1 - NEWRULES, RULESET
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:34,代码来源:tzdbentities.cpp

示例2: ChineseToDateTime

//------------------------------------------------------
// Class:       TChineseCalendar
// Function:    ChineseToDateTime
// Arguments:   TDateTime &
//
// Comments:    This function converts the date held within
//				the TChineseCalendar class to a TDateTime format and 
//				places it in the TDateTime class provided.
//
// Return:      void
//------------------------------------------------------
EXPORT_C void TChineseCalendar::ChineseToDateTime(TDateTime &aDT)
	{
	TArithmeticalDate gregDate;
	TGregorianCalendar greg(iJulianDay);

	greg.GregFromJulianDay(gregDate,iJulianDay);

	aDT.SetMicroSecond(0);
	aDT.SetSecond(0);
	aDT.SetMinute(0);
	aDT.SetHour(0);
	aDT.SetMonth((TMonth)(gregDate.iMonth - KCalConvMonthOffsetByOne));
	aDT.SetDay(gregDate.iDay - KCalConvMonthOffsetByOne);
	aDT.SetYear(gregDate.iYear);
	}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:26,代码来源:Chinese.cpp

示例3: TimePackToRel

datetime_t TimePackToRel(const datepack_t *tp, bool_t Local)
{
    TDateTime Date;
    TTime ot;
	if (!tp) return INVALID_DATETIME_T;
    Date.SetYear(tp->Year);
    Date.SetMonth((TMonth)(tp->Month-1));
    Date.SetDay(tp->Day-1);
    Date.SetHour(tp->Hour);
    Date.SetMinute(tp->Minute);
    Date.SetSecond(tp->Second);

    ot = TTime(Date);

    if (Local) 
    {
#ifndef SYMBIAN90
        TLocale locale;
        TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
        ot -= universalTimeOffset;
        if (locale.QueryHomeHasDaylightSavingOn())
        {
            TTimeIntervalHours daylightSaving(1);
            ot -= daylightSaving;
        }
#else
        RTz TzServer;
        if (TzServer.Connect()==KErrNone)
        {
            CTzConverter* Converter = CTzConverter::NewL(TzServer); 
            Converter->ConvertToUniversalTime(ot);
            delete Converter;
            TzServer.Close();
        }
#endif
    }

    return SymbianToDateTime(ot);
}
开发者ID:ViFork,项目名称:ResInfo,代码行数:39,代码来源:date_symbian.cpp

示例4: ParseTimeStrMilliL

void TAzenqosEngineUtils::ParseTimeStrMilliL(const TDesC& str,TTime &time)
	{
		TInt instrlen = str.Length();
		if(str.Length() != KTimeStampMillisecStrLen )
			User::Leave(KErrBadName);

		TDateTime date;

		TPtrC ptr(0,0);
		TInt pos=0;
		TLex lex;
		TInt val;

		//_LIT(KTimeStampMillisecFormat,"%02d%02d%02d_%02d:%02d:%02d.%03d");

		///year
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		val+=2000;
		User::LeaveIfError(date.SetYear(val));

		//month
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<1 || val > 12)//month should be at least 1 so we can set as symbian format: month-1
			User::Leave(KErrGeneral);
		val--;//Symbian format EJanuary is 0
		User::LeaveIfError(date.SetMonth((TMonth)val));

		//day
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<1 || val > 31)//day limit
			User::Leave(KErrGeneral);
		val--;//Symbian format EJanuary is 0
		User::LeaveIfError(date.SetDay(val));


		//skip '_'
		pos+=1;

		//HH
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<0 || val > 23)//0 to 23 Hrs
			User::Leave(KErrGeneral);
		User::LeaveIfError(date.SetHour(val));

		//skip ':'
		pos+=1;

		//MM
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<0 || val > 59)//0 to 59 mins
			User::Leave(KErrGeneral);
		User::LeaveIfError(date.SetMinute(val));

		//skip ':'
		pos+=1;

		//SS
		ptr.Set(str.Mid(pos,2));
		pos+=2;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<0 || val > 59)//0 to 59 Seconds
			User::Leave(KErrGeneral);
		User::LeaveIfError(date.SetSecond(val));

		//skip '.'
		pos+=1;

		//SSS
		ptr.Set(str.Mid(pos,3));
		pos+=3;
		lex.Assign(ptr);
		val=0;
		User::LeaveIfError(lex.Val(val));
		if(val<0 || val > 999999)//0 to 999999 MicroSeconds
			User::Leave(KErrGeneral);
		User::LeaveIfError(date.SetMicroSecond(val));

		time = date;
//.........这里部分代码省略.........
开发者ID:ykasidit,项目名称:AzqGenUtils,代码行数:101,代码来源:AzenqosEngineUtils.cpp

示例5: RunL


//.........这里部分代码省略.........
									///////////////END not valid
								}

						////////// boyond here is the VALID case


						////////////set device's UTC time
						if(iSyncTimeWhenValid)
							{

										TTime devTime;
										devTime.HomeTime();
										TDateTime dt = devTime.DateTime();


										if(gpsdata.POS_UTC.Length() < 6 || gpsdata.DATE.Length() < 6)
										{
											//line not ready/full... do nothing
										}
										else
										{

											//All NMEA chars are ASCII

											dt.SetHour((gpsdata.POS_UTC[0]-48)*10+(gpsdata.POS_UTC[1]-48));
											dt.SetMinute((gpsdata.POS_UTC[2]-48)*10+(gpsdata.POS_UTC[3]-48));
											dt.SetSecond((gpsdata.POS_UTC[4]-48)*10+(gpsdata.POS_UTC[5]-48));


											dt.SetDay((gpsdata.DATE[0]-48)*10+(gpsdata.DATE[1]-48) -1);

											dt.SetMonth(TMonth((gpsdata.DATE[2]-48)*10+(gpsdata.DATE[3]-48) -1));

											dt.SetYear((gpsdata.DATE[4]-48)*10+(gpsdata.DATE[5]-48)+KY2K);



											if(gpsdata.POS_UTC.Length()>9 && gpsdata.POS_UTC.Find(_L8("."))>0)
											{
												dt.SetMicroSecond((gpsdata.POS_UTC[7]-48)*KONEHUNDREDTHOUSAND+(gpsdata.POS_UTC[8]-48)*KTENTHOUSAND+(gpsdata.POS_UTC[9]-48)*1000);
											}

											devTime = dt;
											devTime += proctime;
#ifdef EKA2
											User::SetUTCTime(devTime);
#else
											//TODO: detect timezone and add accordingly
											TTime hometime(devTime);
											hometime += TTimeIntervalHours(7);
											User::SetHomeTime(hometime);
#endif


											iSyncTimeWhenValid = EFalse;

											CAknConfirmationNote* informationNote = new (ELeave) CAknConfirmationNote(EFalse);
											//informationNote->SetTimeout(CAknNoteDialog::EShortTimeout);
											_LIT(KConfirmText,"GPS TimeSync Successful");
											informationNote->ExecuteLD(KConfirmText);
											//TODO: report to scheduler that device time has changed? OR let scheduler detect device time change?


										}

							}
开发者ID:ykasidit,项目名称:AzqLocmon,代码行数:67,代码来源:AzqBtGPSReader.cpp

示例6: CreateUserTzBasedOnLondonRuleL

void CTzUserDataTest::CreateUserTzBasedOnLondonRuleL(RTz& aRTz, TTest aWhatToTest)
	{
	test.Next(_L("Test Creation user-defined time zone based on London rules"));
	//create a new rule which doesn't have DST saving.
	TTime start (TDateTime(2010, ESeptember, 0, 0, 0, 0, 0));
	TInt year = start.DateTime().Year();
	TMonth month = start.DateTime().Month();
	TInt day = start.DateTime().Day();
	TTzRule newrule(year, 9999, 0, 0, month,  ETzFixedDate, day,  0, ETzWallTimeReference, 120);

	//Get the existing london rule
	_LIT8(KTimeNone, "Europe/London");
	
	CTzId* londonId = CTzId::NewL(KTimeNone());
	CleanupStack::PushL(londonId);
	CTzRules* userrule = aRTz.GetTimeZoneRulesL(*londonId, 0, 9999, ETzUtcTimeReference);
	CleanupStack::PopAndDestroy(londonId); 

	//Use London rule to create a new user-defined rule
	TInt count = userrule->Count();

	//Since the last two rules (TTzRule objects one for summer rule one for winter rule) in existing database covers the years in which a new rule starts.
	//The client has to amend the ending years of those two rules before adding a new rule.
	//We set the ending year for last two rules to 2009 since the new rule starts on 2010

	TTzRule lastRule = (*userrule)[count-1];
	TDateTime dateTimeLast = lastRule.iTo.iTime.DateTime();
	dateTimeLast.SetYear(2009);
	lastRule.iTo.iTime = dateTimeLast;

	TTzRule lastSecondRule = (*userrule)[count-2];
	TDateTime dateTimeLastSecond = lastSecondRule.iTo.iTime.DateTime();
	dateTimeLastSecond.SetYear(2009);
	lastSecondRule.iTo.iTime = dateTimeLastSecond;
		
	CleanupStack::PushL(userrule);
	//Remove last two existing rules
	userrule->RemoveRule(count-1);
	userrule->RemoveRule(count-2);
	
	//Add two rules whoes ending years have been amended
	userrule->AddRuleL(lastRule);
	userrule->AddRuleL(lastSecondRule);
	
	//Add the new rule
	userrule->AddRuleL(newrule);
	//userrule->AddRuleL(newrule);//add the new rule which doesn't have DST
	
	CTzUserNames* newRuleNames = CreateUserDefinedTzNamesLC();
	CTzId* id = iUserData->CreateL(*userrule, *newRuleNames);
	CleanupStack::PushL(id);
	iTzIds.AppendL(id);
	CleanupStack::Pop(id);
	CheckTimeZoneL(*id, *userrule, *newRuleNames);
	CleanupStack::PopAndDestroy(newRuleNames);
		
	RArray<TTime> timesOn;
	CleanupClosePushL(timesOn);
	RArray<TTime> timesOff;
	CleanupClosePushL(timesOff);
	
	// Check UTC offset and DST.
	TTime check = TDateTime(1998, ESeptember, 0, 0, 0, 0, 0); 
	timesOn.AppendL(check);
	check = TDateTime(2005, ESeptember, 0, 0, 0, 0, 0);
	timesOn.AppendL(check);	
	check = TDateTime(2009, ESeptember, 0, 0, 0, 0, 0);
	timesOn.AppendL(check);

	check = TDateTime(2010, ESeptember, 0, 3, 0, 0, 0); 
	timesOff.AppendL(check);
	check = TDateTime(2015, ESeptember, 0, 3, 0, 0, 0);
	timesOff.AppendL(check);	
	check = TDateTime(2020, ESeptember, 0, 3, 0, 0, 0);
	timesOff.AppendL(check);

	if(aWhatToTest==ETimeConversion)
		{
		TestUtcOffsetL(*id,*userrule, timesOn, 60, aRTz);
		TestUtcOffsetL(*id,*userrule, timesOff, 0, aRTz);
		}
	else if(aWhatToTest==EDayLightSave)
		{
		TestDaylightSavingStateL(*id, timesOn, ETrue, aRTz);
		TestDaylightSavingStateL(*id, timesOff, EFalse, aRTz);
		}
	
	CleanupStack::PopAndDestroy(3, userrule);	
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:89,代码来源:tz_userdata.cpp


注:本文中的TDateTime::SetYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。