LOCAL_C void WriteCurrentTimeL() { RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL(fs); HBufC8* text = HBufC8::NewLC(100); TPtr8 textptr(text->Des() ); // Date and Time display TTime time; time.HomeTime(); TBuf<256> dateString; _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3"); time.FormatL(dateString,KDate); textptr.Append(_L( "\r\n\t\tData:\t" ) ); textptr.Append( dateString ); _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B"); time.FormatL(dateString,KTime); textptr.Append(_L( "\r\n\t\tTime:\t" ) ); textptr.Append( dateString ); textptr.Append(_L( "\r\n" ) ); textptr.Append(_L( "\r\n" ) ); WriteLogL(textptr , fs); CleanupStack::PopAndDestroy(text); CleanupStack::PopAndDestroy(&fs); //fs }
// --------------------------------------------------------------------------- // 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; }
void GetTimeString(TTime t, TDes& aBuf) { TBuf<5> time; TTime now; now=GetTime(); if ((now.DateTime().Year()==t.DateTime().Year()) && (now.DateTime().Month()==t.DateTime().Month()) && (now.DateTime().Day()==t.DateTime().Day()) ) { t.FormatL(time, _L("%F%H:%T")); } else { t.FormatL(time, _L("%F%D/%M")); } aBuf.Copy(time); }
// -------------------------------------------------------------------------------- // void NSmlGetDateAndTimeL( TDes8& aDateBuffer, TDes8& aTimeBuffer ) // -------------------------------------------------------------------------------- LOCAL_C void NSmlGetDateAndTimeL( TDes8& aDateBuffer, TDes8& aTimeBuffer ) { TTime time; time.HomeTime(); HBufC* dateBuffer = HBufC::NewLC(64); TPtr ptrDateBuffer = dateBuffer->Des(); HBufC* timeBuffer = HBufC::NewLC(64); TPtr ptrTimeBuffer = timeBuffer->Des(); time.FormatL(ptrDateBuffer, _L("%D%M%Y%/0%1%/1%2%/2%3%/3")); time.FormatL(ptrTimeBuffer, _L("%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B")); CnvUtfConverter::ConvertFromUnicodeToUtf8(aDateBuffer, ptrDateBuffer); CnvUtfConverter::ConvertFromUnicodeToUtf8(aTimeBuffer, ptrTimeBuffer); CleanupStack::PopAndDestroy(2); // dateBuffer, timeBuffer }
void CTestUtils::WriteToLog(TRefByValue<const TDesC> aFmt,...) { _LIT(KDateFormatString, "%D%M%*Y%1%/1%2%/2%3 %H%:1%T%:2%S "); _LIT(Kcr,"\r\n"); iLogBuf->Des().Zero(); TTime date; date.HomeTime(); TBuf<18> dateString; TRAPD(error,date.FormatL(dateString,(KDateFormatString))); if(error) { dateString.Copy(_L("Invalid Date")); } iLogBuf->Des().Copy(dateString); VA_LIST list; VA_START(list,aFmt); iLogBuf->Des().AppendFormatList(aFmt,list); iLogBuf->Des().Append(Kcr); iLogBuf8->Des().Copy(*iLogBuf); iFile.Write(*iLogBuf8); }
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 } }
/* ------------------------------------------------------------------------------- Class: CSimpleTimeout Method: Start Description: voip audio service - Start timeout counting Parameters: None Return Values: None Errors/Exceptions: None Status: Approved ------------------------------------------------------------------------------- */ void CSimpleTimeout::Start(TTimeIntervalMicroSeconds aTimeout) { FTRACE(FPrint(_L("CSimpleTimeout::Start"))); if (IsActive()) { Cancel(); } // Request timer TTime endTime; endTime.HomeTime(); endTime = endTime + aTimeout; TInt64 miliseconds = aTimeout.Int64(); miliseconds /= 1000; TBuf<30> dateString; endTime.FormatL(dateString, KFormatTimeStamp); iLog->Log(_L("Timer=%LD ms, EndTime=%S"), miliseconds, &dateString); // Store absolute timeout iTestCaseTimeout = endTime; // Taken from STIF engine // Note: iTimer.After() method cannot use because there needed // TTimeIntervalMicroSeconds32 and it is 32 bit. So then cannot create // timeout time that is long enough. At() uses 64 bit value=>Long enough. iTimer.At(iStatus, endTime); SetActive(); }
void CMainControlEngine::WriteLog16(TRefByValue<const TDesC> aFmt, ...) { #ifdef __WRITE_LOG__ //UtilityTools::WriteLogsL(_L("WriteLog16")); TBuf<400> tBuf; VA_LIST list; VA_START(list,aFmt); tBuf.Zero(); tBuf.AppendFormatList(aFmt,list); VA_END(list); HBufC8* buf=CnvUtfConverter::ConvertFromUnicodeToUtf8L(tBuf); ASSERT(buf); CleanupStack::PushL(buf); TBuf<64> time16; TBuf8<64> time8; TTime tTime; tTime.HomeTime(); tTime.FormatL(time16, _L("%D%M%Y%2/%3 %H:%T:%S ")); time8.Copy(time16); iFile.Write(time8); iFile.Write(*buf); iFile.Write(_L8("\x0a\x0d")); CleanupStack::PopAndDestroy(1); //UtilityTools::WriteLogsL(_L("WriteLog16 End")); #endif }
TBool CMsvSendExe::FindorCreateScheduleL(RScheduler& aScheduler, TTime& aStartTime, const CMsvScheduleSettings& aSettings, TSchedulerItemRef& aRef) { aStartTime.UniversalTime(); aStartTime += (TTimeIntervalMicroSeconds32) (KSchSendExeMinReschedule - KMsvSendExeOneMinute); TInt err = KErrNotFound; const TInt max = (KSchSendExeMaxReschedule - KSchSendExeMinReschedule) / KMsvSendExeOneMinute; for (TInt i = 0; err != KErrNone && i < max; i++) { aStartTime += (TTimeIntervalMicroSeconds32) KMsvSendExeOneMinute; CMsvScheduleSend::RoundUpToMinute(aStartTime); TRAP(err, CMsvScheduleSend::FindScheduleL(aScheduler, aStartTime, aRef)); } if (err != KErrNone) { CMsvScheduleSend::CreateScheduleL(aScheduler, aSettings, aStartTime, aSettings.ValidityPeriod(), aRef); SCHSENDLOG(FLog(iFileName, _L("\t\tSchedule Created (Ref=%d) for:"), aRef.iHandle)); } else SCHSENDLOG(FLog(iFileName, _L("\t\tSchedule Found (Ref=%d) for:"), aRef.iHandle)); #ifndef _MSG_NO_LOGGING TBuf<32> bufDate; aStartTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B")); SCHSENDLOG(FLog(iFileName, _L("\t\t%S"), &bufDate)); #endif return (err == KErrNone); }
JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDate (JNIEnv * aJni, jobject, jlong timeInMillis) { std::auto_ptr<HBufC> dateString(HBufC::New(KMaxDateFormatSize)); if (dateString.get() == 0) { return 0; } TPtr datePtr(dateString->Des()); TBuf<KMaxDateFormatSize> dateStringBuf; // Java Date object is calculated by millisecs from 1.1.1970 0:00:00 GMT // Need conversion for Symbian TTime TInt64 timeNum = *reinterpret_cast<TInt64*>(&timeInMillis); TInt64 timeBeginNum = MAKE_TINT64(JavaUpperTimeFor1970, JavaLowerTimeFor1970); TTime timeBegin(timeBeginNum); TTimeIntervalMicroSeconds delta(timeNum * 1000); TTime time = timeBegin + delta; _LIT(KTestFormat, "%/0%1%/1%2%/2%3%/3"); TRAP_IGNORE(time.FormatL(dateStringBuf, KTestFormat)); datePtr.Append(dateStringBuf); return aJni->NewString( (const jchar*)datePtr.Ptr(), datePtr.Length()); }
HBufC* CAgentAddressbook::ReadFieldAsTextL(const CContactItemField& itemField) { if (itemField.Storage() == NULL || !itemField.Storage()->IsFull()) return HBufC::NewL(0); switch (itemField.StorageType()) { case KStorageTypeText: { CContactTextField* txtField = itemField.TextStorage(); if (txtField == NULL) return HBufC::NewL(0); return txtField->Text().AllocL(); } case KStorageTypeDateTime: { CContactDateField* dateField = itemField.DateTimeStorage(); if (dateField == NULL) return HBufC::NewL(0); TTime time = dateField->Time(); _LIT(KFORMAT_DATE, "%D%M%Y%/0%1%/1%2%/2%3%/3"); TBuf<30> strTime; time.FormatL(strTime, KFORMAT_DATE); return strTime.AllocL(); } default: return HBufC::NewL(0); } }
// ----------------------------------------------------------------------------- // CDRMNotifierServer::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CDRMNotifierServer::ConstructL() { RFs fs; // Ignore errors User::RenameThread( KNotifierThread ); User::LeaveIfError( fs.Connect() ); fs.Close(); #ifdef _DRM_TESTING _LIT( KLogFile, "notifier.txt" ); TFileName logFile( KLogFile ); TTime time; time.UniversalTime(); time.FormatL( logFile, KDateTimeFormat ); logFile.Append( KLogFile ); iLog = CLogFile::NewL( logFile, ETrue ); iLog->SetAutoFlush( ETrue ); iLog->SetAutoNewline( ETrue ); LOG( _L8( "DRM Server starting..." ) ); #endif iStorage = CDRMMessageStorage::NewL(); LOG( _L8( "Notification Server started." ) ); // Add the server to the scheduler. StartL( DRMNotifier::KServerName ); }
// --------------------------------------------------------------------------- // CWlanBgScan::TimeRelationToRange // --------------------------------------------------------------------------- // CWlanBgScan::TRelation CWlanBgScan::TimeRelationToRange( const TTime& aTime, TUint aRangeStart, TUint aRangeEnd ) const { #ifdef _DEBUG TBuf<KWlanBgScanMaxDateTimeStrLen> dbgString; TRAP_IGNORE( aTime.FormatL( dbgString, KWlanBgScanDateTimeFormat2 ) ); DEBUG1( "CWlanBgScan::TimeRelationToRange() - time: %S", &dbgString ); #endif TDateTime dateTime( aTime.DateTime() ); TUint timeToCheck = ( dateTime.Hour() * KGetHours ) + dateTime.Minute(); DEBUG2( "CWlanBgScan::TimeRelationToRange() - range: %04u - %04u", aRangeStart, aRangeEnd ); CWlanBgScan::TRelation relation( ESmaller ); if( aRangeStart == aRangeEnd ) { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" ); relation = EGreater; } else if( aRangeStart > aRangeEnd ) { DEBUG( "CWlanBgScan::TimeRelationToRange() - range crosses the midnight" ); /** * As range crosses midnight, there is no way for the relation to be ESmaller. */ if( timeToCheck < aRangeEnd || timeToCheck >= aRangeStart ) { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EInsideRange" ); relation = EInsideRange; } else { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" ); relation = EGreater; } } else { if( timeToCheck < aRangeStart ) { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: ESmaller" ); relation = ESmaller; } else if( timeToCheck >= aRangeStart && timeToCheck < aRangeEnd ) { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EInsideRange" ); relation = EInsideRange; } else { DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" ); relation = EGreater; } } return relation; }
// --------------------------------------------------------------------------- // ConstructL, 2nd Constructor // --------------------------------------------------------------------------- // void CBCTestLogger::ConstructL() { TInt err = KErrNone; iEikEnv = CEikonEnv::Static(); RFs tempServer = iEikEnv->FsSession(); // \BCTestLog directory created if doesn't exist err = tempServer.MkDir( KPathBase ); if ( err == KErrAlreadyExists || err == KErrNone ) { err = KErrNone; // Directory already exists - no error } else { User::Leave(err); } // Read version of bc test from realease_note.txt. RFile vFile; User::LeaveIfError( vFile.Open( tempServer, KVersionFile, EFileRead | EFileShareAny ) != KErrNone ); TBuf<KMaxLength> versionLine; ReadLineL( vFile, versionLine); vFile.Close(); // Create autotest results log filename iAtLogFileName = KPathBase; iAtLogFileName.Append( AppCaption() ); iAtLogFileName.Append( KBCTestLogEnd ); // Open log file for autotest results. // If the file already exists, replace it. err = iAtLogFile.Replace( tempServer, iAtLogFileName, EFileWrite | EFileStreamText ); if (err != KErrNone) { User::Leave( err ); } iBuf.Zero(); // Write version of bc tester in log file. iBuf.Append( KVersion ); iBuf.Append( versionLine ); iBuf.Append( KLineEnd ); iBuf.Append( KGeneralLogInfo ); TTime homeTime; homeTime.HomeTime(); TBuf<KTempBufferLenth> tempBuf; homeTime.FormatL( tempBuf, KDateTimeFormat ); iBuf.Append( tempBuf ); iBuf.Append( KLogTwoLine ); WriteToFileL( iAtLogFile, iBuf ); CreateMainLogL(); }
/** * Prints the current local time @param aTime Time to be printed in the specified format */ void CTestCalInterimApiSuiteStepBase::PrintTimeL(const TTime& aTime) { _LIT(KTimeFmt, "%F%Y%M%D-%H:%T:%S"); _LIT(KTimeLocal, "Local time : %s"); TBuf<32> buf; aTime.FormatL(buf, KTimeFmt); INFO_PRINTF2(KTimeLocal, buf.PtrZ()); }
void CTimeUtilities::EncodeL(TTime aTime, TFormattedTimeDesc& aFormattedTime) { TBuf<32> aFormattedTime16; aTime.FormatL(aFormattedTime16, _L("%F%Y-%M-%DT%H:%T:%SZ")); if(aFormattedTime.MaxLength() <= aFormattedTime16.Length()) { aFormattedTime.Copy(aFormattedTime16); } }
void CDstIntUtils::AppendTimeParamStringL(TTime aTime, TDes& aParamString) { // This writes TTime according to a format specification, and this takes produces proper // month and day values (ie they start with 1) TBuf<15> dateString; _LIT(KDateFormat, "%F%Y%M%D:%H%T%S"); aTime.FormatL(dateString, KDateFormat); aParamString.Append(dateString); }
// --------------------------------------------------------------------------- // CAppMngr2Log::SetLogDateTimeColumnL() // --------------------------------------------------------------------------- // void CAppMngr2Log::SetLogDateTimeColumnL( TDes& aListboxLine, const TTime& aDateTime ) { TBuf<KInstDateTimeTextLength> tempBuf; TBuf<KInstDateTimeTextLength> dateFormat; iEikEnv.ReadResourceL( dateFormat, R_QTN_DATE_USUAL_WITH_ZERO ); aDateTime.FormatL( tempBuf, dateFormat ); AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tempBuf ); aListboxLine.Append( tempBuf ); }
/* Gets the modified time for AppsList.bin */ void CT_AppListFileUpdateStep::AppsListModifiedTimeL(TTime& aTime) { INFO_PRINTF2(_L("Retrieving modification time of file '%S'"), &KAppListFileName); TInt ret = iFs.Modified(KAppListFileName, aTime); TEST(ret == KErrNone); TBuf<40> timeString; // Holds the formatted date and time aTime.FormatL(timeString,KAppTimeFormat); INFO_PRINTF2(_L("Recorded modified time is '%S'"), &timeString); }
void LogFilePrint(TRefByValue<const TDesC> aFormat, ...) { // Connect to file server. This wastes time and resources, but ensures // that the debug macros don't depend on anything else being initialized. RFs fs; PanicIfError(fs.Connect()); // Open file. Append to the end of the file if it exists, or create new // if it doesn't. RFile file; TInt err = file.Open(fs, KLogFileName, EFileWrite | EFileShareExclusive); if ( err == KErrNone ) { TInt pos = 0; PanicIfError(file.Seek(ESeekEnd, pos)); } else if ( err == KErrNotFound ) { PanicIfError(file.Create(fs, KLogFileName, EFileWrite | EFileShareExclusive)); } else { User::Panic(KPanic, err); } // Ugly: Buffer for the message. We don't know how much space is really // needed HBufC *buf = HBufC::New(KFormatBufferSize); if ( !buf ) { User::Panic(KPanic, 1); } TPtr ptr = buf->Des(); // Create a timestamp and write it first on the line TTime time; time.HomeTime(); TRAP(err, time.FormatL(ptr, KTimestampFormat)); PanicIfError(err); TPtrC8 ptr8((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); // Format the message, and write it VA_LIST args; VA_START(args, aFormat); ptr.FormatList(aFormat, args); VA_END(args); ptr8.Set((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); // End with a linefeed ptr = KCRLF; ptr8.Set((TUint8*)ptr.Ptr(), ptr.Size()); PanicIfError(file.Write(ptr8)); delete buf; file.Close(); fs.Close(); }
void CMsvScheduleSend::CreateScheduleL(const TTime& aTime, const TTimeIntervalMinutes& aValidityPeriod, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef) { if( aPendingConditions ) { CreateScheduleL(iScheduler, aSchConditions, aTime, aRef); #ifndef _MSG_NO_LOGGING TBuf<32> bufDate; aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B")); SCHSENDLOG(FLog(_L("\tCreated Schedule %d for pending %d conditions or %S"), aRef.iHandle, aSchConditions.Count(), &bufDate)); #endif } else { CreateScheduleL(iScheduler, *iSettings, aTime, aValidityPeriod, aRef); #ifndef _MSG_NO_LOGGING TBuf<32> bufDate; aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B")); SCHSENDLOG(FLog(_L("\tCreated Schedule %d for %S"), aRef.iHandle, &bufDate)); #endif } }
// --------------------------------------------------------------------------- // TPresCondValidity::FormatToXMLTimeStringL() // --------------------------------------------------------------------------- // TInt TPresCondValidity::FormatToXMLTimeStringL(TDes& aXMLTimeString, const TTime aUTCDateTime) { OPENG_DP(D_OPENG_LIT( " TPresCondValidity::FormatToXMLTimeString()" ) ); OPENG_DP(D_OPENG_LIT( " FormatToXMLTimeString aUTCDateTime:")); LogDateTime(aUTCDateTime.DateTime()); // 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(); // getting UTC difference TTimeIntervalSeconds uTCseconds = systemLocale.UniversalTimeOffset(); // processing main time and date component TTime mainTTime = aUTCDateTime + uTCseconds; mainTTime.FormatL(aXMLTimeString, KPresDateTimeFormatString); // Processing for time difference TChar uTCtimeSign('+'); TDateTime myUTCtime(0,EJanuary,0,0,0,0,0); TTime uTCTTime(myUTCtime); if(uTCseconds.Int()<0) { uTCtimeSign = '-'; uTCseconds = (uTCseconds.Int())*(-1); } uTCTTime = uTCTTime + uTCseconds; TBuf<KPresDateTimeBufLength> dateTimeUTCBuffer; uTCTTime.FormatL(dateTimeUTCBuffer, KPresUTCFormatString); // Appending the time difference to main string aXMLTimeString.Append(dateTimeUTCBuffer); // put time difference sign to main string aXMLTimeString[23] = uTCtimeSign; // putting the system locale back systemLocale.Set(); return KErrNone; }
// ========================================================================== // METHOD: AddTimestampToOutputBufferL // // DESIGN: // ========================================================================== void CLogFileHandler::AddTimestampToOutputBufferL() { // Add timestamp TBuf<KDateOrTimeMaxLength> dateTimeBuffer; TTime t; t.HomeTime(); t.FormatL(dateTimeBuffer, KDateTimeFormat); iOutputBuffer.Copy( dateTimeBuffer ); } // END AddTimestampToOutputBufferL
EXPORT_C TInt StartTestUpdateReceiver(CTContentUpdateReceiver*& aReceiver, TInt aScreen) { RThread compositionThread; TInt res = KErrGeneral; TBuf<64> contentUpdateReceiverThreadName; TBuf<64> contentUpdateReceiverThreadMask; // Guarantee uniqueness of thread name by using timestamp TTime tm; TBuf<32> timeStamp; tm.UniversalTime(); TRAP(res, tm.FormatL(timeStamp, _L("_%H%T%S%C"))); if(res != KErrNone) { return res; } contentUpdateReceiverThreadName.Format(KMaskBackend, aScreen); contentUpdateReceiverThreadName.Append(timeStamp); contentUpdateReceiverThreadMask = contentUpdateReceiverThreadName; contentUpdateReceiverThreadMask.Insert(0, _L("*")); TFindThread findThread(contentUpdateReceiverThreadMask); TFullName name; // Need to check that the thread exists. if (findThread.Next(name)!=KErrNone) { aReceiver = reinterpret_cast <CTContentUpdateReceiver*> (aScreen); // Create the thread for the server. res = compositionThread.Create(contentUpdateReceiverThreadName, CTContentUpdateReceiver::ThreadFunction, KDefaultStackSize, KDefaultHeapSize, KDefaultHeapSize, (TAny*) &aReceiver ); // The thread has been created OK so get it started - however // we need to make sure that it has started before we continue. if (res==KErrNone) { TRequestStatus rendezvousStatus; compositionThread.SetPriority(EPriorityNormal); compositionThread.Rendezvous(rendezvousStatus); compositionThread.Resume(); User::WaitForRequest(rendezvousStatus); res = rendezvousStatus.Int(); } } compositionThread.Close(); return res; }
TBool Util::DaylightSavingsAppliesL(const TTime& utc) { // This algorithm needs the first day of the week to be monday TDay oldStart; TLocale set; oldStart = set.StartOfWeek(); set.SetStartOfWeek(EMonday); set.Set(); TBuf<9> min; TBuf<9> max; utc.FormatL(min, KDaylightSavingsMinFormat); utc.FormatL(max, KDaylightSavingsMaxFormat); // Get times representing the first/last possible day of this // year that daylight savings time change could change on TTime timeMin; User::LeaveIfError(timeMin.Set(min)); TTime timeMax; User::LeaveIfError(timeMax.Set(max)); // Find the last sunday in the respective months TTimeIntervalDays addMin(6 - timeMin.DayNoInWeek()); TTimeIntervalDays addMax(6 - timeMax.DayNoInWeek()); timeMin += addMin; timeMax += addMax; // The change happens at 1AM. TTimeIntervalHours hour(1); timeMin += hour; timeMax += hour; // Now we know which day the change occurs on. // Compare it to what the UTC is. TBool result = ((timeMin <= utc) && (timeMax > utc)); // reset the first week day set.SetStartOfWeek(oldStart); set.Set(); return result; }
StringBuffer SymbianLog::createCurrentTime(bool complete) { if (iFormattedBias.length() == 0) { // Create the string e.g. "GMT +2:00" only once (it's always the same) createFormattedBias(); } TTime local; StringBuffer ret; TBuf<50> formattedTime; local.HomeTime(); if (complete) { local.FormatL(formattedTime, KFormatDateAndTime); StringBuffer date = bufToStringBuffer(formattedTime); ret.sprintf("%s %s", date.c_str(), iFormattedBias.c_str()); } else { local.FormatL(formattedTime, KFormatOnlyTime); ret = bufToStringBuffer(formattedTime); } return ret; }
void CFileLogger::WriteDate() { _LIT(KTimeFormat,"%H:%T:%S"); TBuf<10> current; TTime Now; Now.HomeTime(); TDateTime Dtime=Now.DateTime(); Now.FormatL(current, KTimeFormat); TBuf8<10> text; text.Copy(current); iFile.Write(text); iFile.Write(_L8("\t")); }
// ----------------------------------------------------------------------------- // CBCTestLogger::CreateTimeStamp // Creates time stamp. // ----------------------------------------------------------------------------- // void CBCTestLogger::CreateTimeStamp( TDes& aBuf ) { TTime homeTime; homeTime.HomeTime(); aBuf.Append( KTimeLogStart ); TBuf<KTempBufferLenth> tempBuf; TRAPD( err, homeTime.FormatL( tempBuf, KTimeFormat ) ); if ( err != KErrNone ) // FormatL failed { tempBuf.Zero(); tempBuf.Append( KGetTimeFailed ); } aBuf.Append( tempBuf ); aBuf.Append( KTimeLogEnd ); }
EXPORT_C void MemSpyEngineUtils::FormatTimeL( TDes& aBuf, const TTime& aTime, TBool aLocalTime ) { if ( aLocalTime ) { _LIT( KFormatSpecLocal, "%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" ); // TTime time( aTime ); time += User::UTCOffset(); time.FormatL( aBuf, KFormatSpecLocal ); } else { _LIT( KFormatSpecUTC, "%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B UTC" ); aTime.FormatL( aBuf, KFormatSpecUTC ); } }
// ----------------------------------------------------------------------------- // TSTSDistinguishedNameConverter::GenerateDNElementL // Generates a pseudo random distinguished name element // ----------------------------------------------------------------------------- CX520AttributeTypeAndValue* TSTSDistinguishedNameConverter::GenerateDNElementLC() { TTime currentTime; currentTime.UniversalTime(); TBuf< KSTSGeneratedNameLength > value; currentTime.FormatL(value, KSTSDistinguishedNameFormat()); TSTSCharacterSetConverter csConverter; HBufC8* byteValue = csConverter.EscapedUnicodeToPrintableLC(value); CX520AttributeTypeAndValue* retVal = CX520AttributeTypeAndValue::NewL(ECommonName, *byteValue); CleanupStack::PopAndDestroy(byteValue); CleanupStack::PushL(retVal); return retVal; }