本文整理汇总了C++中TTime::DateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TTime::DateTime方法的具体用法?C++ TTime::DateTime怎么用?C++ TTime::DateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTime
的用法示例。
在下文中一共展示了TTime::DateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PopulateOffPeakListL
void CPigeonScheduledSend::PopulateOffPeakListL()
{
//There are no existing off peak times set up
//So no need to remember them
iOffPeakList->Reset();
TTime t;
TDateTime d;
t.HomeTime();
t -= TTimeIntervalHours(1);
d = t.DateTime();
TTimeIntervalMinutes twoHours = 120;
TMsvOffPeakTime current(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
iOffPeakList->AppendL(current);
t -= TTimeIntervalDays(1);
d = t.DateTime();
TMsvOffPeakTime yesterday(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
iOffPeakList->AppendL(yesterday);
t += TTimeIntervalDays(2);
d = t.DateTime();
TMsvOffPeakTime tomorrow(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours);
iOffPeakList->AppendL(tomorrow);
}
示例2: AutoIntervalChangeAt
// ---------------------------------------------------------------------------
// CWlanBgScan::AutoIntervalChangeAt
// ---------------------------------------------------------------------------
//
TTime CWlanBgScan::AutoIntervalChangeAt()
{
TTime currentTime;
currentTime.HomeTime();
TDateTime change_time( currentTime.DateTime() );
#ifdef _DEBUG
change_time = currentTime.DateTime();
TBuf<KWlanBgScanMaxDateTimeStrLen> timeNow;
TRAP_IGNORE( currentTime.FormatL( timeNow, KWlanBgScanDateTimeFormat ) );
DEBUG1( "CWlanBgScan::AutoIntervalChangeAt() - time now: %S", &timeNow );
#endif
switch( TimeRelationToRange( currentTime, iBgScanSettings.bgScanPeakStartTime, iBgScanSettings.bgScanPeakEndTime ) )
{
case ESmaller:
{
change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
change_time.SetMinute( iBgScanSettings.bgScanPeakStartTime % KGetHours );
change_time.SetSecond( KZeroSeconds );
currentTime = change_time;
break;
}
case EInsideRange:
{
change_time.SetHour( iBgScanSettings.bgScanPeakEndTime / KGetHours );
change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
change_time.SetSecond( KZeroSeconds );
currentTime = change_time;
if( iBgScanSettings.bgScanPeakStartTime > iBgScanSettings.bgScanPeakEndTime )
{
DEBUG( "CWlanBgScan::AutoIntervalChangeAt() - peak end happens tomorrow" );
currentTime += TTimeIntervalDays( KAddOneDay );
}
else
{
DEBUG( "CWlanBgScan::AutoIntervalChangeAt() - peak end happens today" );
}
break;
}
case EGreater:
{
change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
change_time.SetSecond( KZeroSeconds );
currentTime = change_time;
currentTime += TTimeIntervalDays( KAddOneDay );
break;
}
}
#ifdef _DEBUG
change_time = currentTime.DateTime();
TBuf<KWlanBgScanMaxDateTimeStrLen> dbgString;
TRAP_IGNORE( currentTime.FormatL( dbgString, KWlanBgScanDateTimeFormat ) );
DEBUG1( "CWlanBgScan::AutoIntervalChangeAt() - interval change to occur: %S", &dbgString );
#endif
return currentTime;
}
示例3: GetAlarmTimeL
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TTime CProfileSettings::GetAlarmTimeL(TTime aTime, TTime aDate)
{
TDateTime NewAlarm(aDate.DateTime().Year(),aDate.DateTime().Month(),aDate.DateTime().Day(),aTime.DateTime().Hour(),aTime.DateTime().Minute(), aTime.DateTime().Second(),0);
TTime RetAlarm(NewAlarm);
return RetAlarm;
}
示例4: LocationUpdate
/** Adjusts system time if required. The decision whether the adjustment is needed or not
is based on the following criterias:
- satellite time must be present in the location update
- time threshold must be exceeded
- time from a last adjustment is greater than a defined interval.
@param aStatus An error code.
@param TPositionSatelliteInfo Position and time information.
If clock adjustment takes place the TPosition::iTime is
re-set to the satellite time.
@see CLbsAdmin
@see TPositionSatelliteInfo
*/
void CAutoClockAdjust::LocationUpdate(TInt aStatus, TPositionSatelliteInfo& aPosInfo)
{
LBSLOG(ELogP1, "CAutoClockAdjust::LocationUpdate()\n");
TTimeIntervalMicroSeconds timeCorr;
TTime sysTime;
TInt err;
// If adjustment on, no error, and satellite information present
if ((iClockAdjustSetting == CLbsAdmin::EClockAdjustOn) && (aStatus == KErrNone) &&
((aPosInfo.PositionClassType() & EPositionSatelliteInfoClass) == EPositionSatelliteInfoClass))
{
// Is is time do do another time adjustment?
sysTime.UniversalTime();
if (Abs(sysTime.MicroSecondsFrom(iLastAdjustment).Int64()) > (1000*iAdjustInterval))
{
const TPositionSatelliteInfo& satInfo = static_cast<const TPositionSatelliteInfo&>(aPosInfo);
err = CalculateTimeCorrection(satInfo, timeCorr);
if (err == KErrNone)
{
// Is threshold exceeded?
if (Abs(timeCorr.Int64()) > (1000*iAdjustThreshold))
{
sysTime.UniversalTime();
sysTime += timeCorr;
LBSLOG(ELogP9, "->S CGpsSetClockBase::SetUTCTime() ClockModule\n");
LBSLOG5(ELogP9, " > TTime sysTime = %02d:%02d:%02d.%06d\n", sysTime.DateTime().Hour(),
sysTime.DateTime().Minute(),
sysTime.DateTime().Second(),
sysTime.DateTime().MicroSecond());
err = iSetClockImpl->SetUTCTime(sysTime);
LBSLOG2(ELogP9, " Return = %d\n", err);
if (err == KErrNone)
{
// Sync the position time with the satellite time
// to avoid re-adjusting the system time by the manual clock adjustment component.
TPosition pos;
aPosInfo.GetPosition(pos);
pos.SetTime(aPosInfo.SatelliteTime());
aPosInfo.SetPosition(pos);
LBSLOG2(ELogP2, "ACTION: Clock Adjusted by %ld\n", timeCorr.Int64());
}
}
if (err == KErrNone)
{
// Remember the current time even if threshold not exceeded
iLastAdjustment = sysTime;
}
else
{
LBSLOG_WARN2(ELogP3, "Clock Adjustment failed. Error: %d\n", err);
}
}
}
}
}
示例5: CreateScheduledReminderL
void CFMSServer::CreateScheduledReminderL()
{
FLOG(_L("CFMSServer::CreateScheduledReminderL ()"));
_LIT(KFotaScheduleExe, "Z:\\sys\\bin\\fotaschedulehandler.exe");
RScheduler scheduler;
TTsTime startTime;
TTime time;
time.HomeTime();
time = time + (TTimeIntervalHours(1));
startTime.SetLocalTime(time);
User::LeaveIfError(scheduler.Connect());
CleanupClosePushL(scheduler);
//Creating a persistent daily schedule
TSchedulerItemRef persistentScheduleItem;
CArrayFixFlat<TScheduleEntryInfo2>* entries = new CArrayFixFlat<TScheduleEntryInfo2> (1);
CleanupStack::PushL(entries);
persistentScheduleItem.iName = TUid::Uid(KFMSServerUid).Name();
//TScheduleEntryInfo2 scentry1(startTime, EDaily, 1, 1);
TScheduleEntryInfo2 scentry1;
scentry1.SetStartTime(startTime);
scentry1.SetInterval(1);
scentry1.SetIntervalType(TIntervalType(EHourly));
scentry1.SetValidityPeriod((TTimeIntervalMinutes) 1440); //1440 min = 24 hrs or 1 day
entries->AppendL(scentry1);
scheduler.Register(TFileName( KFotaScheduleExe ), 0 );
TInt ret = scheduler.CreatePersistentSchedule(persistentScheduleItem, *entries);
FLOG(_L("created schedule %d %d:%d"), persistentScheduleItem.iHandle,
time.DateTime().Hour(), time.DateTime().Minute());
if (ret == KErrNone)
{
TTaskInfo taskInfo;
taskInfo.iName = TUid::Uid(KFMSServerUid).Name();
taskInfo.iRepeat = 1; //Repeat once
taskInfo.iPriority = 1;
TFotaScheduledUpdate fotareminder(-1, -1);
TPckg<TFotaScheduledUpdate> fotareminderpkg(fotareminder);
HBufC* data = HBufC::NewLC(fotareminderpkg.Length());
data->Des().Copy(fotareminderpkg);
TInt err = scheduler.ScheduleTask(taskInfo, *data, persistentScheduleItem.iHandle);
FLOG(_L("Schedule creation error %d"), err);
CleanupStack::PopAndDestroy(data);
}
CleanupStack::PopAndDestroy(entries);
CleanupStack::PopAndDestroy(&scheduler); // xx
}
示例6: LockScreenLockedUnLocked
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CExPolicy_Server::LockScreenLockedUnLocked(TBool aSetOn)
{
if(aSetOn)
{
TFindFile PrivFolder(iFsSession);
if(KErrNone == PrivFolder.FindByDir(KtxDatabaseName, KNullDesC))// finds the drive
{
TParsePtrC Hjelppp(PrivFolder.File());
TFileName FilNammm;
FilNammm.Copy(Hjelppp.Drive());
FilNammm.Append(KtxLockScreenInfName);
RFile DonewFil;
if(KErrNone == DonewFil.Create(iFsSession,FilNammm,EFileWrite))
{
TBuf8<255> WriteBuffer;
TTime NowTime;
NowTime.HomeTime();
WriteBuffer.Copy(iImsi);
WriteBuffer.Append(_L8(": "));
WriteBuffer.AppendNum(NowTime.DateTime().Day());
WriteBuffer.Append(_L8("/ "));
WriteBuffer.AppendNum(NowTime.DateTime().Month());
WriteBuffer.Append(_L8("/ "));
WriteBuffer.AppendNum(NowTime.DateTime().Year());
WriteBuffer.Append(_L8(" -- "));
WriteBuffer.AppendNum(NowTime.DateTime().Hour());
WriteBuffer.Append(_L8(": "));
WriteBuffer.AppendNum(NowTime.DateTime().Minute());
DonewFil.Write(WriteBuffer);
DonewFil.Close();
}
}
}
else
{
TFindFile PrivFolder(iFsSession);
if(KErrNone == PrivFolder.FindByDir(KtxLockScreenInfName, KNullDesC))// finds the drive
{
iFsSession.Delete(PrivFolder.File());
}
}
return HadNonClearedLockScreen();
}
示例7: ConvertRepeatToAgnL
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertRepeatToAgnL
// Makes conversion from framework PIM item repeat rule to native entry repeat.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertRepeatToAgnL(
const MPIMEventItem& aEventItemData, CCalEntry& aAgnEntry)
{
JELOG2(EPim);
const MPIMRepeatRuleData* repeatRuleData = aEventItemData.GetRepeat();
TTime eventStart = aAgnEntry.StartTimeL().TimeUtcL();
TCalRRule agnRRule = PIMRepeatRuleConverter::ConvertSupportedRepeatToAgnL(
*repeatRuleData, eventStart);
if ((aAgnEntry.EntryTypeL() == CCalEntry::EAnniv) && (agnRRule.Type()
!= TCalRRule::EYearly))
{
User::Leave(KErrArgument);
}
if (agnRRule.Type() == TCalRRule::EWeekly)
{
__ASSERT_ALWAYS(agnRRule.Interval() <= 2, User::Leave(KErrArgument));
}
else // other than weekly
{
__ASSERT_ALWAYS(agnRRule.Interval() == 1, User::Leave(KErrArgument));
}
// Use local time to check the day since UTC times provide incorrect
// results if the compared dates are near midnight
TTime untilLocal = agnRRule.Until().TimeLocalL();
TTime startLocal = aAgnEntry.StartTimeL().TimeLocalL();
// Validate that repeat rule is correct. The end of the repeat rule
// must be greater than the event start and it must not be within
// the same day as the start of the event
if (untilLocal != Time::NullTTime())
{
__ASSERT_ALWAYS(untilLocal >= startLocal, User::Leave(KErrAbort));
TTimeIntervalDays intervalDays = untilLocal.DaysFrom(startLocal);
// Interval smaller than one day. Check that the day is not the same
if (intervalDays < TTimeIntervalDays(1))
{
__ASSERT_ALWAYS(untilLocal.DateTime().Day()
!= startLocal.DateTime().Day(), User::Leave(KErrAbort));
}
}
// Repeat Rules OK
aAgnEntry.SetRRuleL(agnRRule);
CopyExceptionDatesToAgnL(*repeatRuleData, aAgnEntry);
}
示例8: TTimeIntervalSeconds
static struct tm& as_struct_tm (const time_t& t, struct tm& res)
{
TTime us = UNIX_BASE + TTimeIntervalSeconds(t);
TDateTime dt = us.DateTime();
res.tm_sec = dt.Second();
res.tm_min = dt.Minute();
res.tm_hour = dt.Hour();
res.tm_mday = dt.Day() + 1;
res.tm_mon = dt.Month();
res.tm_year = dt.Year() - 1900;
// EPOC32 counts the year day as Jan 1st == day 1
res.tm_yday = us.DayNoInYear() - 1;
// EPOC32 counts the weekdays from 0==Monday to 6==Sunday
res.tm_wday = us.DayNoInWeek() + 1;
if (res.tm_wday==7)
res.tm_wday=0; // Sunday==0 in a struct tm
// newlib just sets this field to -1
// tm_isdst doesn't really make sense here since we don't
// know the locale for which to interpret this time.
res.tm_isdst = -1;
return res;
}
示例9: TimerExpired
void CBuddycloudListComponent::TimerExpired(TInt aExpiryId) {
if(aExpiryId == KDragTimerId) {
#ifdef __SERIES60_40__
if(iDraggingAllowed) {
iDragVelocity = iDragVelocity * 0.95;
iScrollbarHandlePosition += TInt(iDragVelocity);
CBuddycloudListComponent::RepositionItems(false);
RenderScreen();
if(Abs(iDragVelocity) > 0.05) {
iDragTimer->After(50000);
}
}
#endif
}
else if(aExpiryId == KTimeTimerId) {
#ifdef __3_2_ONWARDS__
HBufC* aTitle = iEikonEnv->AllocReadResourceLC(R_LOCALIZED_STRING_APPNAME);
SetTitleL(*aTitle);
CleanupStack::PopAndDestroy();
#else
TTime aTime;
aTime.HomeTime();
TBuf<32> aTextTime;
aTime.FormatL(aTextTime, _L("%J%:1%T%B"));
SetTitleL(aTextTime);
TDateTime aDateTime = aTime.DateTime();
iTimer->After((60 - aDateTime.Second() + 1) * 1000000);
#endif
}
}
示例10: Debug
GLDEF_C void Debug( TRefByValue<const TDesC> aText, ... )
{
#ifdef WINS
VA_LIST args;
VA_START( args, aText );
TBuf<KLogLineLength> buf;
buf.FormatList( aText, args );
RFileLogger logger;
TInt ret=logger.Connect();
if (ret==KErrNone)
{
logger.SetDateAndTime( EFalse,EFalse );
logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );
TBuf<KLogTimeFormatLength> timeStamp;
TTime now;
now.HomeTime();
TDateTime dateTime;
dateTime = now.DateTime();
timeStamp.Format( KLogTimeFormat,
dateTime.Hour(), dateTime.Minute(),
dateTime.Second(), dateTime.MicroSecond() );
buf.Insert( 0, timeStamp );
logger.Write(buf);
}
logger.Close();
VA_END( args );
#else
RDebug::Print(aText);
#endif
}
示例11: DoExitChecksNowL
void CMgAppUi::DoExitChecksNowL(void)
{
if(!IsDrawerOn())
{
CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
cmdLine->SetCommandL(EApaCommandRun);
cmdLine->SetExecutableNameL(KtxServerFileName);
RApaLsSession ls;
ls.Connect();
ls.StartApp(*cmdLine);
ls.Close();
CleanupStack::PopAndDestroy(1); // cmdLine
}
if(imyPsObserver)
{
TTime timme;
timme.HomeTime();
imyPsObserver->SetPropertyL(timme.DateTime().MicroSecond());
}
}
示例12: WriteDateStamp
void CTestTransaction::WriteDateStamp(const TDateTime &aDate)
{
TDateTime date;
TTime now;
TBool iEOL = (aDate.Year() == K_OUTOFBOUNDS_YEAR);
if (iEOL)
{
now.HomeTime();
date = now.DateTime();
}
else
date = aDate;
TTime t(date);
TBuf<128> dateTimeString;
TRAPD(err, t.FormatL(dateTimeString, KDateFormat));
if (err == KErrNone)
{
if (iEOL)
Machine()->MsgPrintf(_L("[%S] "), &dateTimeString);
else
Log(_L("[%S]\r\n"), &dateTimeString);
}
}
示例13: 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
}
}
示例14: FormatTimeSimple
void MemSpyEngineUtils::FormatTimeSimple( TDes& aBuf, const TTime& aTime )
{
const TDateTime dt = aTime.DateTime();
//
_LIT( KTimeFormatSpec, "%04d%02d%02d %02d:%02d:%02d" );
aBuf.Format( KTimeFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second() );
}
示例15: GetEventInformation
// ----------------------------------------------------
// CAlfExCalendarEngine::NumberOfEvents
// ----------------------------------------------------
void CAlfExCalendarEngine::GetEventInformation(
const TTime& aDate,
TInt aIndex,
TDes& aTextBuffer)
{
aTextBuffer.Zero();
TInt count = KErrNotFound;
TDateTime requestedDate = aDate.DateTime();
const TInt arrayCount = iCalendarEventArray.Count();
for(TInt loop = 0; loop < arrayCount; loop++ )
{
TDateTime eventDate = iCalendarEventArray[loop].iItemDay.DateTime();
if(eventDate.Day() == requestedDate.Day() &&
eventDate.Month() == requestedDate.Month() &&
eventDate.Year() == requestedDate.Year())
{
count++;
}
if(aIndex == count)
{
aTextBuffer.Copy(iCalendarEventArray[loop].iItemText);
loop = arrayCount;
}
}
}