本文整理汇总了C++中TTime::SecondsFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ TTime::SecondsFrom方法的具体用法?C++ TTime::SecondsFrom怎么用?C++ TTime::SecondsFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTime
的用法示例。
在下文中一共展示了TTime::SecondsFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertAlarmToAgnL
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertAlarmToAgnL
// Converts alarm from PIM item to a native entry. The alarm is calculated
// from the start date of the event and if it is not present, the alarm field
// is ignored because there is no possibility to calculate it
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertAlarmToAgnL(const MPIMEventItem& aItem,
CCalEntry& aEntry)
{
JELOG2(EPim);
const MPIMItemData& itemData = aItem.ItemData();
// Note that start time must be set before alarm can be calculated
// Add start to the item so alarm can be properly converted. The
// native entry does not accept alarm value if start is not present
if (itemData.CountValues(EPIMEventStart) == 0)
{
User::Leave(KErrArgument);
}
else
{
ConvertDateFieldToAgnL(aItem, aEntry, EPIMEventStart);
}
__ASSERT_DEBUG(aEntry.StartTimeL().TimeUtcL() != Time::NullTTime(),
User::Panic(KPIMPanicCategory, EPIMPanicInvalidState));
// Get alarm value from the Java item. There should be only one alarm
// value supported by the PIM API because native entries do not support
// multiple alarm values.
const TPIMFieldData alarmData = itemData.ValueL(EPIMEventAlarm, 0);
TInt value = alarmData.IntegerValue();
// Count the alarm value from the start date of the event
TTime entryStart = aEntry.StartTimeL().TimeLocalL();
const TPIMFieldData startData = itemData.ValueL(EPIMEventStart, 0);
TPIMDate startTime = startData.DateValue();
ConvertTimeL(startTime, EPIMDateLocal);
TTimeIntervalSeconds temp(0);
User::LeaveIfError(entryStart.SecondsFrom(startTime, temp));
// Add difference between PIM API start and start which has been
// converted to the item (in case if the date has been changed, it is
// reflected here)
value += temp.Int();
// Check that if the alarm has passed to the following day. In this case,
// the alarm is transferred back to 12 o'clock of the current start date
TTime alarmTime(entryStart - TTimeIntervalSeconds(value));
// Temporary date. This date is used when calculating if the alarm
// value has passed to the following date.
TTime startOfNextDay(StartOfDay(startTime + TTimeIntervalDays(1)));
if (alarmTime >= startOfNextDay)
{
alarmTime = StartOfDay(entryStart);
alarmTime += TTimeIntervalSeconds(KPIMDefaultAlarmInterval);
User::LeaveIfError(entryStart.SecondsFrom(alarmTime, temp));
value = temp.Int();
}
// Convert the alarm value to the native entry
SetAlarmToEntryL(aEntry, value);
}
示例2: IsTimeBeforeL
/*
-------------------------------------------------------------------------
-------------------------------------------------------------------------
*/
TBool CExPolicy_Server::IsTimeBeforeL(TTime& aTime,TTime& aCompare)
{
TBool IsBefore(EFalse);
TTimeIntervalMinutes MinInterval(0);
TTimeIntervalHours HourInterval(0);
TTimeIntervalSeconds SecInterval(0);
TTime TimeNow;
TimeNow.HomeTime();
TTimeIntervalDays DaysInterval = aTime.DaysFrom(aCompare);
if(DaysInterval.Int() <= 0)
{
aTime.HoursFrom(aCompare,HourInterval);
if(HourInterval.Int() <= 0)
{
aTime.MinutesFrom(aCompare,MinInterval);
if(MinInterval.Int() <= 0)
{
aTime.SecondsFrom(aCompare, SecInterval);
if(SecInterval.Int() <= 0)
{
IsBefore = ETrue;
}
}
}
}
return IsBefore;
}
示例3: DeleteGroupMembersCheckPersist
LOCAL_C void DeleteGroupMembersCheckPersist()
{
test.Next(_L("Delete Group Members Check Persist"));
//
TTime before;
before.UniversalTime();
for(TInt ii=1;ii<KLargeSizeRecords+1;ii++)
{
CntTest->Db()->DeleteContactL(ii);
if (ii%100==0)
test.Printf(_L(".")); // Just to show some life
}
TTime after;
after.UniversalTime();
TTimeIntervalSeconds secondsTaken;
after.SecondsFrom(before,secondsTaken);
test.Printf(_L(" TIME: %d Secs"),secondsTaken.Int());
test.Printf(_L("\n"));
//test.Getch();
//
CContactIdArray* groups = CntTest->Db()->GetGroupIdListL();
CleanupStack::PushL(groups);
CContactItem* group = CntTest->Db()->ReadContactL((*groups)[0]);
CContactIdArray* memberArray = STATIC_CAST(CContactGroup*,group)->ItemsContainedLC();
test(memberArray->Count()==0);
delete group;
CleanupStack::PopAndDestroy(2); // groups memberArray
}
示例4: DeleteManyGroups
LOCAL_C void DeleteManyGroups()
{
//
test.Next(_L("Delete MANY Groups"));
TTime before;
before.UniversalTime();
for(TInt ii=6;ii<KLargeSizeRecords+6;ii++)
{
CntTest->Db()->DeleteContactL(ii);
if (ii%100==0)
test.Printf(_L(".")); // Just to show some life
}
TTime after;
after.UniversalTime();
TTimeIntervalSeconds secondsTaken;
after.SecondsFrom(before,secondsTaken);
test.Printf(_L(" TIME: %d Secs"),secondsTaken.Int());
test.Printf(_L("\n"));
//test.Getch();
//
test.Next(_L("Test Card Membership Update"));
test(CntTest->Db()->CountL()==5); // 5 contacts + own card
for(TInt jj=1;jj<6;jj++)
// add cards to all groups
{
CContactItem* contact = CntTest->Db()->ReadContactLC(jj);
CContactIdArray* groups = STATIC_CAST(CContactCard*, contact)->GroupsJoinedLC();
test(groups->Count()==0);
CleanupStack::PopAndDestroy(2); // contact groups
}
CntTest->Db()->CompactL();
}
示例5: RunL
void CPosition::RunL()
{
TPosition position;
iPositionInfo.GetPosition(position);
TTime now;
now.UniversalTime();
TTimeIntervalSeconds interval = 0;
now.SecondsFrom(position.Time(), interval);
LOGARG("Interval between retrieved position and current time: %d secs", interval.Int());
// Compare that retrieved data is not outdated
if (iStatus == KErrNone && interval.Int() < 300)
{
iObserver.PositionUpdateL(iStatus.Int(), position);
}
else if (iStatus == KErrTimedOut)
{
iObserver.PositionUpdateL(iStatus.Int(), position);
}
else
{
iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus);
SetActive();
iState = EGps;
}
}
示例6:
GLDEF_C TInt E32Main()
{
CTrapCleanup* cleanup;
cleanup=CTrapCleanup::New();
__UHEAP_MARK;
test.Title();
test.Start(_L("Starting tests..."));
TTime timerC;
timerC.HomeTime();
DoTests();
TTime endTimeC;
endTimeC.HomeTime();
TTimeIntervalSeconds timeTakenC;
TInt r=endTimeC.SecondsFrom(timerC,timeTakenC);
test(r==KErrNone);
test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
test.End();
test.Close();
__UHEAP_MARKEND;
delete cleanup;
return(KErrNone);
}
示例7: UpdateLogEventParam
TInt CEventLogger::UpdateLogEventParam(CLogEvent& aLogEvent, TInt aRConnectionStatusId, const TUid& aDataEventType, const TInt64& aBytesSent, const TInt64& aBytesReceived)
{
TTime time;
TInt ret =KErrNone;
time.UniversalTime();
TTimeIntervalSeconds interval(0);
if (time.SecondsFrom(iCurrentLogEvent->Time(),interval) != KErrNone)
{
interval = 0; // no duration available ->error
}
if (KConnectionStatusIdNotAvailable != aRConnectionStatusId)
{
//status needs to be updated
TBuf<KLogMaxStatusLength > logStatusBuf;
iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok
aLogEvent.SetStatus(logStatusBuf);
}
if ( aDataEventType != TUid::Null())
{
aLogEvent.SetEventType(aDataEventType);
}
aLogEvent.SetDuration(interval.Int()); //0 or not
//check if data metrics need to be updated
TInt64 byteInfoNotAvailable(KBytesInfoNotAvailable);
if ((aBytesReceived != byteInfoNotAvailable) && (aBytesSent != byteInfoNotAvailable))
{
TBuf8<KDatabufferSize> dataBuffer;
dataBuffer.Num(aBytesSent);
dataBuffer.Append(TChar(','));
dataBuffer.AppendNum(aBytesReceived);
TRAP(ret, aLogEvent.SetDataL(dataBuffer));
}
return ret;
}
示例8: TimeIsBeforeL
// Return true if first argument is iLeewaySeconds or more before the second
// argument. Hence it is conservative, and should be always used "positively"
// to check for error conditions.
TBool COCSPValidator::TimeIsBeforeL(const TTime& aBefore, const TTime& aAfter)
{
TTimeIntervalSeconds difference;
const TTimeIntervalSeconds leeway(iLeewaySeconds);
User::LeaveIfError(aAfter.SecondsFrom(aBefore, difference));
return (difference > leeway);
}
示例9: PutL
TUint CTupleStoreImpl::PutL(TTupleType aTupleType, const TTupleName& aTupleName, const TDesC& aSubName,
const TComponentName& aComponent,
const TDesC8& aSerializedData, TBBPriority aPriority, TBool aReplace,
const TTime& aLeaseExpires, TBool aKeepExisting)
{
CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("PutL"));
if (aTupleName.iModule.iUid == KBBAnyUidValue ||
aTupleName.iId == KBBAnyId ||
aComponent.iModule.iUid == KBBAnyUidValue ||
aComponent.iId == KBBAnyId) User::Leave(KErrArgument);
TUint ret;
{
TAutomaticTransactionHolder ath(*this);
TBool exists=SeekNameL(aTupleType, aTupleName, aSubName);
if (exists && aKeepExisting) {
UpdateL();
iTable.SetColL(ELeaseExpires, aLeaseExpires);
MDBStore::PutL();
return 0;
} else if (exists && aReplace) {
UpdateL();
} else {
InsertL();
iTable.SetColL(ETupleType, aTupleType);
iTable.SetColL(ENameModule, aTupleName.iModule.iUid);
iTable.SetColL(ENameId, aTupleName.iId);
iTable.SetColL(ENameSubName1, aSubName);
iTable.SetColL(ENameSubName2, aSubName.Left(iSubNameIndexLength));
iTable.SetColL(EPriority, aPriority);
iTable.SetColL(EComponentModule, aComponent.iModule.iUid);
iTable.SetColL(EComponentId, aComponent.iId);
}
ret=iTable.ColUint(ETupleId);
if (aSerializedData.Length() > 0) {
RADbColWriteStream w; w.OpenLA(iTable, EData);
w.WriteUint32L(aSerializedData.Length());
w.WriteL(aSerializedData);
w.CommitL();
} else {
iTable.SetColNullL(EData);
}
iTable.SetColL(ELeaseExpires, aLeaseExpires);
MDBStore::PutL();
}
if (aLeaseExpires < iNextExpiry) {
TTime now=GetTime();
TTimeIntervalSeconds s;
aLeaseExpires.SecondsFrom(now, s);
TInt wait=s.Int();
iTimer->Wait(wait);
}
return ret;
}
示例10: as_time_t
GLDEF_C time_t as_time_t(const TTime& t)
{
TTimeIntervalSeconds res;
TInt err = t.SecondsFrom(UNIX_BASE, res);
if (err)
return -1;
else
return res.Int();
}
示例11: CleanOldTuplesL
void CTupleStoreImpl::CleanOldTuplesL()
{
CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("CleanOldTuplesL"));
SwitchIndexL(EIndexLeaseExpires);
iTable.FirstL();
iTable.GetL();
TTupleName name; TBuf<KMaxTupleSubNameLength> subname;
TTime expires;
if (iTable.IsColNull(ELeaseExpires)) {
expires=TTime(0);
} else {
expires=iTable.ColTime(ELeaseExpires);
}
TTime now=GetTime();
TInt tupletype=-1;
while (now > expires) {
if ( iTable.IsColNull(ELeaseExpires) ) {
UpdateL();
iTable.SetColL( ELeaseExpires, Time::MaxTTime() );
MDBStore::PutL();
} else {
tupletype=iTable.ColInt(ETupleType);
if (tupletype == ETupleDataOrRequest) {
name.iModule.iUid=iTable.ColInt(ENameModule);
name.iId=iTable.ColInt(ENameId);
subname=iTable.ColDes16(ENameSubName1);
}
MDBStore::DeleteL();
if (tupletype == ETupleDataOrRequest) {
iDeleteNotification.NotifyDeleted(name, subname);
}
}
if (! iTable.NextL() ) return;
iTable.GetL();
if (iTable.IsColNull(ELeaseExpires)) {
expires=TTime(0);
} else {
expires=iTable.ColTime(ELeaseExpires);
}
}
if ( expires == TTime(0) || expires == Time::MaxTTime() ) return;
TTimeIntervalSeconds s;
TInt err=expires.SecondsFrom(now, s);
if (err==KErrOverflow) return;
iNextExpiry=expires;
TInt wait=s.Int();
iTimer->Wait(wait);
}
示例12: WriteToLog
void CMemoryUsageLogger::WriteToLog()
{
//seconds passed since start of application
TTime currentTime;
TTimeIntervalSeconds seconds;
currentTime.UniversalTime();
currentTime.SecondsFrom(iStartTime, seconds);
if (seconds.Int() <= 60)
{
TInt heapTotal = 0;
TInt heapAvail = 0;
TInt chunkTotal = 0;
TInt chunkAvail = 0;
TInt cellsTotal = 0;
TInt cellsAvail = 0;
TInt heapStackTotal = 0;
TInt ramTotal = 0;
TInt ramAvail = 0;
//get system memory info from hardware abstraction layer
HAL::Get(HAL::EMemoryRAM, ramTotal);
HAL::Get(HAL::EMemoryRAMFree, ramAvail);
//get process UID
TSecureId processUid(iProcess.SecureId());
//get various heap and chunk memory sizes
iHeap.AllocSize(heapTotal);
if (heapTotal > iMaxHeapTotal)
{
iMaxHeapTotal = heapTotal;
}
iHeap.Available(heapAvail);
chunkTotal = iHeap.Size();
chunkAvail = chunkTotal - heapTotal;
if (chunkTotal > iMaxChunkTotal)
{
iMaxChunkTotal = chunkTotal;
}
//get cells info
cellsTotal = iHeap.Count(cellsAvail);
//sum up the total heap and stack sizes
heapStackTotal = heapTotal + iStackSize;
//create log text and write to log file
TBuf16<KLbsDevLogMaxBufSize> logData;
logData.Format(KLogFormat, seconds.Int(), processUid.iId, iStackSize, heapTotal, heapAvail, chunkTotal, chunkAvail, cellsTotal, cellsAvail, heapStackTotal, ramTotal, ramAvail);
iLogger.Write(logData);
}
}
示例13: AddToPyDict
void AddToPyDict(python_ptr<PyObject> &dict, char* name, const TTime& value)
{
TDateTime epoch; epoch.Set(1970, EJanuary, 0, 0, 0, 0, 0);
TTime e(epoch);
TInt unixtime=0;
TTimeIntervalSeconds secs;
if (value!=TTime(0)) {
User::LeaveIfError(value.SecondsFrom(e, secs));
unixtime=secs.Int();
}
AddToPyDict(dict, name, unixtime);
}
示例14: RestoreDateAndTime
LOCAL_C void RestoreDateAndTime()
{
if (StartTimeSet)
{
TTime aCurrentTime;
aCurrentTime.UniversalTime();
TTimeIntervalSeconds aDuration;
if (!aCurrentTime.SecondsFrom(StartTime,aDuration))
StartTime+=aDuration;
User::SetHomeTime(StartTime);
StartTimeSet=EFalse;
}
}
示例15: DoCancelL
// ------------------------------------------------------------------------
// CDRMConsume::DoCancelL
// ------------------------------------------------------------------------
//
void CDRMConsume::DoCancelL()
{
DRMLOG( _L( "CDRMConsume::DoCancelL" ) );
if ( iCurrentDelay )
{
TTimeIntervalSeconds secs;
TTime trustedTime;
TBool secureTime;
CTimer::DoCancel();
secureTime = SECURETIME( trustedTime );
trustedTime.SecondsFrom( iTime, secs );
#ifdef RD_DRM_METERING
// Update total cumulative time for content metering purposes
iTotalCumulativeTime = iTotalCumulativeTime.Int() + secs.Int();
#endif
// If the top level timed counter has not been activated yet
// increment the counter
if( ISSET( iTimedCounts, KChildToplevelCount ) )
{
iCumulativeDelayTop = iCumulativeDelayTop.Int() + secs.Int();
}
// If the child timed counter has not been activated yet
// increment the counter
if( ISSET( iTimedCounts, KChildPermCount ) )
{
iCumulativeDelayChild = iCumulativeDelayChild.Int() + secs.Int();
}
// Always >= 0.
ConsumeTimedItemsL( secs,
secureTime,
trustedTime );
iCurrentDelay = 0;
}
UpdateDBL();
if ( SERVER->HasActiveCountConstraint( *iURI ) )
{
SERVER->RemoveActiveCountConstraint( *iURI );
}
DRMLOG( _L( "CDRMConsume::DoCancel ok" ) );
}