// ----------------------------------------------------
// 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;
            }
        }
    }
Example #2
0
TBool CHttpHdrTest::CompareDate(TDateTime aDate1, TDateTime aDate2)
	{
	return ((aDate1.Year() == aDate2.Year()) &&
			(aDate1.Month() == aDate2.Month()) &&
			(aDate1.Day() == aDate2.Day()) &&
			(aDate1.Hour() == aDate2.Hour()) &&
			(aDate1.Minute() == aDate2.Minute()) &&
			(aDate1.Second() == aDate2.Second()) &&
			(aDate1.MicroSecond() == aDate2.MicroSecond()));
	}
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() );
    }
Example #4
0
// -----------------------------------------------------------------------------
// CCapInfo::WriteSolutionTagL()
// Writes SyncSolutionsService solution data to capability object.
// -----------------------------------------------------------------------------
//
void CCapInfo::WriteSolutionTagL( const TDesC& aContentName,
        const TSConSolutionInfo& aSolution )
    {
    TRACE_FUNC_ENTRY;
    _LIT( KFormatUID, "UID=0x%08x" );
    _LIT( KFormatName, "Name=%S" );
    _LIT( KFormatDate, "Timestamp=%04d%02d%02dT%02d%02d%02dZ" );
    
    WriteTagL( EExt, TXmlParser::EElementBegin );
    WriteValueL( EXNam, aContentName );
    
    TFileName temp;
    temp.Format( KFormatUID, aSolution.iUid );
    WriteValueL( EXVal, temp );
    
    temp.Format( KFormatName, &aSolution.iSolutionName );
    WriteValueL( EXVal, temp );
    
    if ( aSolution.iTime.Int64() != 0 )
        {
        // write time
        TDateTime time = aSolution.iTime.DateTime();
        temp.Format( KFormatDate, time.Year(), time.Month() + 1,
            time.Day() + 1, time.Hour(), time.Minute(), time.Second() );
        WriteValueL( EXVal, temp );
        
        }
    
    
    WriteTagL( EExt, TXmlParser::EElementEnd );
    TRACE_FUNC_EXIT;
    }
// ---------------------------------------------------------------------------
// TPresCondValidity::LogDateTime()
// ---------------------------------------------------------------------------
//
void TPresCondValidity::LogDateTime(TDateTime aDateTime)
    {
    OPENG_DP(D_OPENG_LIT( "         %d, %d, %d, %d, %d, %d, %d"),
                    aDateTime.Year(), aDateTime.Month()+1, aDateTime.Day()+1,
                    aDateTime.Hour(), aDateTime.Minute(), aDateTime.Second(),
                                                    aDateTime.MicroSecond() );
    }
Example #6
0
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;
}
TVerdict CTestImpBDay::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TInt numberOfCases = 0;
	
	while(ETrue)
		{
		TBuf<90> config(KImportBDay);
		TPtrC ptrexpUTC = GetExpectedUTCFromIniL(numberOfCases, config, ETrue);
		if(ptrexpUTC==KNullDesC)
			{
			break;	
			}
			
		INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1);
		iExpectedBDay = FormatDateTime(ptrexpUTC);
		TBuf<90> pathVCF(KPathImportBDay);
		OpenBDAYVCFAndImportItemL(pathVCF, numberOfCases); // Imports vcf 
	
		TDateTime importedDateTime = iBDayFromImport.DateTime();
		TDateTime expectedDateTime = iExpectedBDay.DateTime();
	
		// If birthday does not match, test will fail
		if((importedDateTime.Year() != expectedDateTime.Year()) ||     
		   (importedDateTime.Month() != expectedDateTime.Month()) ||
		   (importedDateTime.Day() != expectedDateTime.Day()) )
			{
			INFO_PRINTF1(_L("Imported Birthday not correct"));
		   	SetTestStepResult(EFail);
		   	return TestStepResult();
			}
		else
			{
			INFO_PRINTF1(_L("Imported Birthday as expected"));
			SetTestStepResult(EPass);
			}
			
		numberOfCases++;
		}
		
	return TestStepResult();
	}
// ----------------------------------------------------
// CAlfExCalendarEngine::NumberOfEvents
// ----------------------------------------------------
TInt CAlfExCalendarEngine::NumberOfEvents(const TTime& aDate)
    {
    TInt count = 0;
    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++;
            }
        }
    return count;
    }
void TAzenqosEngineUtils::MakeTimeStrMilli(TTime &time,TDes& str) //str should be at least 19 in length
{

	const TInt KThousand = 1000;

	TDateTime date = time.DateTime();
	str.Format(KTimeStampMillisecFormat,date.Year()%2000,date.Month()+1,date.Day()+1,date.Hour(),date.Minute(),date.Second(),date.MicroSecond()*KThousand);

}
// ----------------------------------------------------
// CAlfExCalendarEngine::EventsAvailable
// ----------------------------------------------------
TBool CAlfExCalendarEngine::EventsAvailable(const TTime& aDate)
    {
    TBool ret( EFalse );
    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())
            {
            ret = ETrue;
            break;
            }
        }
    return ret;
    }
Example #11
0
TBool CTestExBDayLocal::CheckImportedBDay()
	{
	TDateTime importedDateTime = iBDayFromImport.DateTime();
	TDateTime exportedDateTime = iBDayLocal.DateTime();
	
	//checks if exported and imported birthday macthes, which it should, otherwise test failed
	if((importedDateTime.Year() != exportedDateTime.Year()) ||
	 (importedDateTime.Month() != exportedDateTime.Month()) ||
	 (importedDateTime.Day() != exportedDateTime.Day()) )
		{
		INFO_PRINTF1(_L("Export and Import of birthday does not match (incorrect)"));
		return EFalse;
		}
	else
		{
		INFO_PRINTF1(_L("Export and Import of birthday macthes (correct)"));
		return ETrue;
		}	
	}
Example #12
0
//------------------------------------------------------
// Class:       TChineseCalendar
// Function:    DateTimeToChinese
// Arguments:   TDateTime &
//
// Comments:    Sets the date held in the given TDateTime
//				class to the TChineseCalendar class
//
// Return:      void
//------------------------------------------------------
EXPORT_C void TChineseCalendar::DateTimeToChinese(const TDateTime &aDT)
	{
	TArithmeticalDate gregDate;
	TGregorianCalendar greg;

	gregDate.iDay = aDT.Day() + KCalConvMonthOffsetByOne;
	gregDate.iMonth = (TInt)aDT.Month() + KCalConvMonthOffsetByOne;
	gregDate.iYear = aDT.Year();

	iJulianDay = greg.GregToJulianDay(gregDate);
	}
EXPORT_C void CMemSpyEngineOutputSink::DataStreamTimeStampBeginL( const TTime& aTime )
{
    const TDateTime dt( aTime.DateTime() );

    // Build it up...
    HBufC* spec = HBufC::NewL( KMaxFileName );
    TPtr pName( spec->Des() );
    pName.Format( KMemSpyDataStreamFolderNameFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());

    DataStreamTimeStampEnd();
    iDataStreamTimeStampSpecifier = spec;
}
void CMemSpyEngineSinkMetaData::ConstructL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime )
{
    iRoot = aRoot.AllocL();
    iContext = aContext.AllocL();
    iFolder = aFolder.AllocL();
    iExtension = aExtension.AllocL();

    const TDateTime dt = aFolderTime.DateTime();
    HBufC* spec = HBufC::NewLC( KMaxFileName );
    TPtr pName( spec->Des() );
    pName.Format( KMemSpyDataStreamFolderNameFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
    iFolderTimeStamp = pName.AllocL();
    CleanupStack::PopAndDestroy( spec );
}
Example #15
0
void CDTSYLogger::WriteRecord(const TDesC8& aText)
	{
	if(iValid)
		{
		TBuf8<KGenericBufferSize> buf;
		TTime now;
		now.UniversalTime();
		TDateTime dateTime;
		dateTime = now.DateTime();
		buf.Format(_L8 ("%04d/%02d/%02d %02d.%02d:%02d:%06d "),dateTime.Year(),dateTime.Month()+1, dateTime.Day()+1,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
		buf.AppendFormat(_L8("%S\015\012"),&aText);
		iFile.Write(buf);
		iFile.Flush();
		}
	}
Example #16
0
/*
-----------------------------------------------------------------------
-----------------------------------------------------------------------
*/
TUint32 CZipCompressor::MsDosDateTime( TTime aTime )
{
	TDateTime dateTime = aTime.DateTime();

	TUint8 day 		= dateTime.Day() + 1;
	TUint8 month 	= dateTime.Month() + 1;
	TUint8 year 	= dateTime.Year() - 1980;
	TUint8 seconds 	= dateTime.Second();
	TUint8 minutes 	= dateTime.Minute();
	TUint8 hours 	= dateTime.Hour();
	
	TUint32 date = 0;
	date |= ( year & 0x3f ) << 9;
	date |= ( month & 0x0f ) << 5;
	date |= ( day & 0x1f );
	date <<= 16;
	date |= ( hours & 0x1f ) << 11;
	date |= minutes << 5;
	date |= seconds >> 1;
	return date;
}
Example #17
0
bool_t GetDatePacked(datetime_t t, datepack_t *tp, bool_t Local)
{
	TDateTime Date;
    TTime ot;
	if (!tp || t == INVALID_DATETIME_T) return 0;
	
    ot = DateTimeToSymbian(t);

    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->ConvertToLocalTime(ot);
            delete Converter;
            TzServer.Close();
        }
#endif
    }

	Date = ot.DateTime();
	tp->Year = Date.Year();
	tp->Month = (int)Date.Month() + 1;
	tp->Day = Date.Day()+1;
	tp->Hour = Date.Hour();
	tp->Minute = Date.Minute();
	tp->Second = Date.Second();
	return 1;
}
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::WriteStartingTags
 // Writes header tags for GPX file
 // ---------------------------------------------------------------------------
void CGpxConverterAO::WriteStartingTags()
	{
	LOG("CGpxConverterAO::WriteStartingTags ,begin");
	TPtr8 writePtr = iWriteBuf->Des();
	TPtr formatter = iFormatBuf->Des();
	
	// write starting tags
	writePtr.Copy( KTagXml );
	writePtr.Append( KTagGpxStart );
	iGpxFile.Write( writePtr );
	
	writePtr.Copy( KTagMetaStart );
	formatter.Format( KTagName, &iGpxFileName );
	writePtr.Append( formatter );
	iGpxFile.Write( writePtr );
	
	TTime timeStamp( 0 );
	timeStamp.UniversalTime();
	TDateTime datetime = timeStamp.DateTime();
	
	formatter.Format( KTagTimeStamp, datetime.Year(), datetime.Month() + 1, datetime.Day() + 1,
			datetime.Hour(), datetime.Minute(), datetime.Second() );
	writePtr.Copy( formatter );
	iGpxFile.Write( writePtr );
	
	if ( iBoundaries )
		{
		formatter.Format( KTagBounds, iBoundaries->minLatitude, iBoundaries->minLongitude, 
				iBoundaries->maxLatitude, iBoundaries->maxLongitude );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		}
	writePtr.Copy( KTagMetaEnd );
	iGpxFile.Write( writePtr );
	
	writePtr.Copy( KTagTrackStart );
	iGpxFile.Write( writePtr );
	LOG("CGpxConverterAO::WriteStartingTags ,end");
	}
// -----------------------------------------------------------------------------
// CTFAStifTestLog::ConstructL
// -----------------------------------------------------------------------------
void CTFAStifTestLog::ConstructL( void )
    {
    TFileName fileName;
    TTime time;
    time.HomeTime();
    TDateTime dateTime = time.DateTime();
    RThread thread;
#ifdef __LOG_HTML__
    _LIT( KSuffix, "html" );
#else
    _LIT( KSuffix, "txt" );
#endif
    fileName.Format( _L( "%02d%02d%02d_%02d%02d%02d_%x.%S" ), 
        dateTime.Year() - 2000, dateTime.Month() + 1, dateTime.Day() + 1, 
        dateTime.Hour(), dateTime.Minute(), dateTime.Second(), 
        (TUint)thread.Id(), &KSuffix );
    iLogger = CStifLogger::NewL( _L( "c:\\logs\\testframework\\" ), fileName,
        CStifLogger::ETxt, CStifLogger::EFile, ETrue, EFalse, EFalse, EFalse, EFalse );
    iOverflowHandler = new ( ELeave ) TTFAOverflowHandler;
#ifdef __LOG_HTML__
    iLogger->Log( _L8( "<html><head><title>TFA Log</title></head>\r\n<body>\r\n" ) );
#endif
    }
Example #20
0
const wchar *C_dir::ScanGet(dword *atts, dword *size, S_date_time *dt){

   if(!find_data)
      return NULL;

   S_scan_data *sd = (S_scan_data*)find_data;
   if(sd->index >= sd->count)
      return NULL;

   const TEntry &e = (*sd->list)[sd->index++];
   if(atts){
      *atts = 0;
      if(e.IsArchive()) *atts |= C_file::ATT_ARCHIVE;
      if(e.IsHidden()) *atts |= C_file::ATT_HIDDEN;
      if(e.IsReadOnly()) *atts |= C_file::ATT_READ_ONLY;
      if(e.IsSystem()) *atts |= C_file::ATT_SYSTEM;
      if(e.IsDir()) *atts |= C_file::ATT_DIRECTORY;
   }
   if(size)
      *size = e.iSize;
   if(dt){
      const TDateTime st = e.iModified.DateTime();
      dt->year = word(st.Year());
      dt->month = word(st.Month());
      dt->day = word(st.Day());
      dt->hour = word(st.Hour());
      dt->minute = word(st.Minute());
      dt->second = word(st.Second());

      dt->sort_value = dt->GetSeconds() + dt->GetTimeZoneMinuteShift()*60;
      dt->SetFromSeconds(dt->sort_value);
      dt->sort_value = dt->GetSeconds();
   }
   TFileName fn = e.iName;
   sd->tmp = (const wchar*)fn.PtrZ();
   return sd->tmp;
}
Example #21
0
TVerdict CTestExRevUTC::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TBuf<90> pathVCF(KExportRevUTCFile);
	ExportItemL(pathVCF, EFalse);
	
	// read from the disk.
	ImportItemL(pathVCF,EFalse);
	TDateTime t = iRecordedTime.DateTime();
	TDateTime t1 = iTimeFromImport.DateTime();
	
	INFO_PRINTF7(_L("Recorded Last Modified Date Year: %d, Month: %d, Day: %d, Recorded Time Hr: %d, Min: %d, Sec: %d "), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second());
	INFO_PRINTF7(_L("Imported Last Modified Date Year: %d, Month: %d, Day: %d, Imported Time Hr: %d, Min: %d, Sec: %d "), t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second());
	
	TTimeIntervalSeconds secondsDifference;
	User::LeaveIfError(iTimeFromImport.SecondsFrom(iRecordedTime, secondsDifference));
	TInt difference = secondsDifference.Int();
	
	if (difference < 2 && difference > -2)
		{
		INFO_PRINTF1(_L("Recorded and Imported DateTime match"));
		SetTestStepResult(EPass);
		}
	else
		{
		INFO_PRINTF1(_L("Recorded and Imported DateTime does not match"));
		SetTestStepResult(EFail);
		}
		
	return TestStepResult();
	}
Example #22
0
TVerdict CTestImpRevLocal::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TInt numberOfCases = 0;
	
	while(ETrue)
		{
		TBuf<90> config(KImportRevLocal);
		TPtrC ptrexpUTC = GetExpectedUTCFromIniL(numberOfCases, config, EFalse);
		if(ptrexpUTC==KNullDesC)
			{
			break;	
			}
			
		INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1);
		iExpectedUTC = FormatDateTime(ptrexpUTC);
		TBuf<80> pathVCF(KPathImportRevLocal);
		OpenVCFAndImportItemL(pathVCF, iFsSession, numberOfCases); // Imports vcf 
	
		TDateTime t = iTimeFromImport.DateTime();
		TDateTime t1 = iExpectedUTC.DateTime();
		INFO_PRINTF7(_L("Imported Date Year: %d, Month: %d, Day: %d, Imported Time Hr: %d, Min: %d, Sec: %d "), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second());
		INFO_PRINTF7(_L("Expected Date Year: %d, Month: %d, Day: %d, Expected Time Hr: %d, Min: %d, Sec: %d "), t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second());
	
		if (iExpectedUTC==iTimeFromImport) // checks if imported time is correct
			{
			INFO_PRINTF1(_L("Imported Time as local (correct)"));
			SetTestStepResult(EPass);	
			}
		else
			{
			INFO_PRINTF1(_L("Imported Time not imported as local (NOT CORRECT)"));
			SetTestStepResult(EFail);
			return TestStepResult();
			}
		
		numberOfCases++;
		}

	return TestStepResult();
	}
void CDummyCalendarApp::AddEntryL(TInt aNumToAdd, TBool isParent, TBool isRepeat)
	{
	test.Next(_L("Adding entries"));

	TBuf<50> summary;
	TBuf<50> location;
	TBuf<50> description;

    

	iEntries.ResetAndDestroy();
	for (TInt index=0; index<aNumToAdd; index++)
		{
		TBuf8<255> buf;
		buf.Append(_L("GuidId"));
		buf.AppendNum(index);
		HBufC8* guid = buf.AllocLC();   // need to be pushed to ...

		CCalEntry::TType entryType=(index%2==0)?CCalEntry::ETodo:CCalEntry::EAppt;

		CCalEntry* entry = NULL;
		if(isParent)
			{
			entry = CreateCalEntryL(entryType, guid);
			}
		else
			{
			TTime localTime(KRecurrIdLocalTime);
			TCalTime recurrenceId;
			recurrenceId.SetTimeLocalL(localTime);
			entry = CCalEntry::NewL(entryType, guid, CCalEntry::EMethodAdd, 1, recurrenceId, CalCommon::EThisAndFuture);
			}
		CleanupStack::Pop(guid);
		iEntries.AppendL(entry);

		TInt year = -1;
		TInt month = -1;
		TInt day = -1;
		
		if (isParent)
		    {
    		year = index % 5 + 2001;    // Any year in the range: 2001 - 2005
    		month = index % 12;         
    		day = index % 28;
		    }
        else
            {
            // if this is a child entry, use the recurrence local time as the entry start time 
            // so it won't be out of range
            TCalTime recurrId = entry->RecurrenceIdL(); 
            TDateTime localTime = recurrId.TimeLocalL().DateTime();               
            year = localTime.Year();
            month = localTime.Month();
            day = localTime.Day();    
            }
		
		TTime start(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0));
		TTime end(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0));
		end += TTimeIntervalDays(1);

		SetEntryStartAndEndTimeL(entry,start,end);
				
		RandomText(summary);
		entry->SetSummaryL(summary);
		
		RandomText(location);
		entry->SetLocationL(location);
		
		RandomText(description);
		entry->SetDescriptionL(description);

		if(isRepeat)
			{
			//create a daily repeat rule and make sure its repeat start\end date is within the deleting time range
			TCalRRule rpt(TCalRRule::EDaily);
			rpt.SetInterval(1);
			TCalTime repeatStart;
			TCalTime repeatend;
			if(isParent)
				{
				//make sure the repeat time is within the delete time range
				repeatStart.SetTimeLocalL(TDateTime(2000, EJune, 0, 0, 0, 0, 0));
				repeatend.SetTimeLocalL(TDateTime(2006, EJune, 0, 0, 0, 0, 0));
				}
			else if (index<aNumToAdd/2)
				{
                // if this is a child entry, use the entry's recurrance time as repeating rule
                // start time 
                TCalTime recurrId = entry->RecurrenceIdL(); 
				
				// make sure the repeat time is within the delete time range for the first half entries
				repeatStart.SetTimeLocalL(recurrId.TimeLocalL());	// June 1, 2003 00:00:00
				repeatend.SetTimeLocalL(recurrId.TimeLocalL() + TTimeIntervalMonths(1));  // July 1, 2003 00:00:00
				}
			else
				{
				//make sure the repeat time is out of the delete time range for the second half entries
				repeatStart.SetTimeLocalL(TDateTime(2003, EJune, 0, 0, 0, 0, 0));
				repeatend.SetTimeLocalL(TDateTime(2007, EJune, 0, 0, 0, 0, 0));
				}

			rpt.SetDtStart(repeatStart); 
			rpt.SetUntil(repeatend);
			entry->SetRRuleL(rpt);
			}
		}
	
	TInt entriesStored(0);
	iLocalEntryView->StoreL(iEntries, entriesStored); //temp
	test(entriesStored == iEntries.Count());
	}
// ---------------------------------------------------------------------------
// CLbtCleanupHandler::WriteCleanupDataToFileL
// ---------------------------------------------------------------------------
//
void CLbtCleanupHandler::WriteCleanupDataToFileL()
	{
	FUNC_ENTER("CLbtCleanupHandler::WriteCleanupDataToFileL");	
	
	RFs fs;
	User::LeaveIfError( fs.Connect() );
	
	CleanupClosePushL( fs );
    
    // Obtain the file path
    TFileName file;
    
    // Gets the path in which the file can be created
    fs.SessionPath(file);

    // Create the file Directory ie the private directory of the process
    fs.MkDirAll(file);
    
    // Append the name of the file
    file.Append(KLbtAppCleanupFileName);
    
    // Open write stream to write to the file
    RFileWriteStream writeStream;
    
    // Open the file to replace the contents. If the file is not preset
    // this method will create the file
    TInt error = writeStream.Replace( fs, file, EFileWrite );    
    if( error != KErrNone )
    	{
    	ERROR("Opening of cleanup file failed with : %d", error);
    	writeStream.Close();
    	CleanupStack::PopAndDestroy(); //fs
    	User::Leave(error);
    	}
    CleanupClosePushL( writeStream );
    
    // First write the number of cleanup items
    writeStream.WriteInt16L( iCleanupItems.Count() );

	for(TInt i=0;i<iCleanupItems.Count();++i)
		{
		RArray<TLbtTriggerId>& triggers = iCleanupItems[i]->GetTriggers();
		
		// Write the trigger ids into the file
		writeStream.WriteInt16L( triggers.Count() );
		for(TInt j=0;j<triggers.Count();++j)
			{
			writeStream.WriteUint32L( triggers[j] );
			}
		
		// Write the time into the file
		const TDateTime dateTime = iCleanupItems[i]->GetTime().DateTime();
		
		// Write the year
		writeStream.WriteInt32L( dateTime.Year() );
		
		// Write the month
		writeStream.WriteInt32L( dateTime.Month() );
		
		// Write the day
		writeStream.WriteInt32L( dateTime.Day() );
		}
    
    CleanupStack::PopAndDestroy(2); //fs and writeSteam    
	}
void CAgnCalendarConverter209::InternalizeRepeatRuleL(RReadStream& aStream, CAgnRptDef& aRptDef) const
	{
    TBool hasRepeatRule = aStream.ReadUint8L();

	// TAgnRpt 
	//
	// This data member of CAgnRptDef is different in 9.3 
    //
	if (hasRepeatRule)
		{
		TAgnRpt* rule = NULL;
		TAgnRpt::TType rptType = static_cast<TAgnRpt::TType>(aStream.ReadUint8L());
		
		// Intenalize data in base class for repeat definitions
		// (TAgnRpt)
		//
		TInt64 timeInt64;
		aStream >> timeInt64; // ignore start time
		aStream >> timeInt64;
		TAgnCalendarTime untilTime;
		untilTime.SetUtcL(timeInt64); // not right if the entry is floating, this must be fixed once the time mode is known

		TUint16 interval;
		aStream >> interval;
		
		// skip iRptNextOnly and iRptForever (not used in 9.3)
		aStream.ReadUint8L();
		aStream.ReadUint8L();
		
		// Internalize data in classes derived from TAgnRpt
		//
		switch(rptType)
			{
			case TAgnRpt::EDaily:
				//Nothing else to internalize for rpt rule
				rule = new (ELeave) TAgnDailyRpt(aRptDef);
				CleanupStack::PushL(rule);
				break;
			case TAgnRpt::EWeekly:
				{
				rule = new (ELeave) TAgnWeeklyRpt(aRptDef);
				CleanupStack::PushL(rule);
				TAgnWeeklyRpt* weeklyRule = static_cast<TAgnWeeklyRpt*>(rule);
				TUint8 weeklyRptDays = aStream.ReadUint8L();
				if (weeklyRptDays & EBit1)
					{
					weeklyRule->SetDay(EMonday);	
					}
				if (weeklyRptDays & EBit2)
					{
					weeklyRule->SetDay(ETuesday);
					}
				if (weeklyRptDays & EBit3)
					{
					weeklyRule->SetDay(EWednesday);
					}
				if (weeklyRptDays & EBit4)
					{
					weeklyRule->SetDay(EThursday);
					}
				if (weeklyRptDays & EBit5)
					{
					weeklyRule->SetDay(EFriday);
					}
				if (weeklyRptDays & EBit6)
					{
					weeklyRule->SetDay(ESaturday);
					}
				if (weeklyRptDays & EBit7)
					{
					weeklyRule->SetDay(ESunday);
					}

				TDay firstDayOfWeek = static_cast<TDay>(aStream.ReadUint8L());
				weeklyRule->SetFirstDayOfWeek(firstDayOfWeek);
				}
				break;
			case TAgnRpt::EMonthlyByDates:
				{
				rule = new (ELeave) TAgnMonthlyByDatesRpt(aRptDef);
				CleanupStack::PushL(rule);
				TInt32 monthlyRptDates;
				aStream >> monthlyRptDates;
				for (TInt i = 0; i <= 30; ++i) // check 31 dates
					{
					TInt dateToCheck = 1 << i;
					if (monthlyRptDates & dateToCheck)
						{
						static_cast<TAgnMonthlyByDatesRpt*>(rule)->SetDate(i);
						}
					}
				}
				break;
			case TAgnRpt::EMonthlyByDays:
				{
				rule = new (ELeave) TAgnMonthlyByDaysRpt(aRptDef);
				CleanupStack::PushL(rule);
				TAgnMonthlyByDaysRpt* monthlyRule = static_cast<TAgnMonthlyByDaysRpt*>(rule);
				
				TInt weekInMonth = 0;
				while (weekInMonth <= 4) // 5 weeks in month (1st, 2nd, 3rd, 4th, last)
					{
					TUint8 monthlyRptDays = aStream.ReadUint8L();
					if (monthlyRptDays & EBit1)
						{
						monthlyRule->SetDay(EMonday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));	
						}
					if (monthlyRptDays & EBit2)
						{
						monthlyRule->SetDay(ETuesday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					if (monthlyRptDays & EBit3)
						{
						monthlyRule->SetDay(EWednesday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					if (monthlyRptDays & EBit4)
						{
						monthlyRule->SetDay(EThursday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					if (monthlyRptDays & EBit5)
						{
						monthlyRule->SetDay(EFriday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					if (monthlyRptDays & EBit6)
						{
						monthlyRule->SetDay(ESaturday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					if (monthlyRptDays & EBit7)
						{
						monthlyRule->SetDay(ESunday, static_cast<TAgnRpt::TWeekInMonth>(weekInMonth));
						}
					++weekInMonth;
					}
				}
				break;
			case TAgnRpt::EYearlyByDay:
				{
				rule = new (ELeave) TAgnYearlyByDayRpt(aRptDef);
				CleanupStack::PushL(rule);
				TAgnRpt::TWeekInMonth weekInMonth = static_cast<TAgnRpt::TWeekInMonth>(aStream.ReadUint8L());
				TDay day = static_cast<TDay>(aStream.ReadUint8L());
				TDateTime untilDateTime = untilTime.LocalL().DateTime();
				static_cast<TAgnYearlyByDayRpt*>(rule)->FindStartDayL(day, weekInMonth, untilDateTime.Month(), untilDateTime.Year());
				}
				break;
			case TAgnRpt::EYearlyByDate:
				rule = new (ELeave) TAgnYearlyByDateRpt(aRptDef);
				CleanupStack::PushL(rule);
				break;
			default:
				User::Leave(KErrCorrupt);
			}
		rule->SetInterval(interval);
		
		aRptDef.SetRRuleL(*rule);
		aRptDef.SetUntilTime(untilTime);
		CleanupStack::PopAndDestroy(rule);
		}
	}
Example #26
0
TVerdict CTestExBDayLocal::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TInt numberOfCases = 0;
	
	while (ETrue)
		{
		TPtrC ptrBDay = GetBDayL(numberOfCases);
		if(ptrBDay==KNullDesC)
			{
			break;	
			}
		
		INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1);
				
		iBDayLocal = FormatDateTime(ptrBDay);
		TDateTime t = iBDayLocal.DateTime();
		INFO_PRINTF7(_L("Birthday to be exported, Year: %d, Month: %d, Day: %d, Hr: %d, Min: %d, Sec: %d"), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second());
				
		iName = GetNameL(numberOfCases);
		
		iPhone = GetPhoneL(numberOfCases);
		
		TBuf<90> pathVCF(KExportBDayFile);
		ExportItemL(pathVCF, ETrue);
		// read from the disk.
		ImportItemL(pathVCF, ETrue);
		
		if(!CheckImportedBDay())
			{
			SetTestStepResult(EFail);
			return TestStepResult();
			}
			
		numberOfCases++;
		}// End Of While Loop
		
	SetTestStepResult(EPass);
	return TestStepResult();
	}
void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
        QList< FmRestoreInfo > &restoreInfoList,
        const QString& aDrive )
    {
    int targetDrive = DriverNameToNumber( aDrive );    

    restoreInfoList.clear();
    
    ///////
    iDrvAndOpList->Reset();
    iBkupCategoryList->ResetAndDestroy();
    
    for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
        it != drivesAndOperationList.end(); ++it )
        {
        FmBkupDrivesAndOperation* fmDrvAndOp = *it;
        TBkupDrivesAndOperation drvAndOp;
        drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
        drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
        iDrvAndOpList->AppendL( drvAndOp );
        }
    ////////

    CMMCScBkupOpParamsRestoreFull* params =
        CMMCScBkupOpParamsRestoreFull::NewL(
                iDrvAndOpList, FmBkupEngine::EBUCatAllSeparately );
    CleanupStack::PushL( params );

    // Get list of all archives
    RPointerArray< CMMCScBkupArchiveInfo > archives;
    TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
    CleanupStack::PushL( cleanupItem );
    iBkupEngine->ListArchivesL(
        archives,
        params,
        AllowedDriveAttMatchMask(),
        targetDrive );

    // Fill restore info
    TInt count( archives.Count() );
//    restoreInfoList.ReserveL( count );

    for( TInt i( 0 ); i < count; ++i )
        {
        // Content
        CMMCScBkupArchiveInfo& archiveInfo( *archives[ i ] );
        
        TUint32 iContent = BkupToFmgrMask( archiveInfo.Category().iFlags );
        TTime iTime = archiveInfo.DateTime();
        TInt iDrive = archiveInfo.Drive();
        TDateTime iDateTime = iTime.DateTime();
        
        int h       = iDateTime.Hour();
        int m       = iDateTime.Minute();
        int s       = iDateTime.Second();
        int year    = iDateTime.Year();
        int month   = iDateTime.Month() + 1;
        int day     = iDateTime.Day()+1;
        QTime time( h, m, s);
        QDate date( year, month, day );
        
        QDateTime dateTime( date, time );
        dateTime = dateTime.toLocalTime();
        
        FmRestoreInfo restoreInfo( iContent, dateTime, NumberToDriverName( iDrive ) );
        restoreInfoList.append( restoreInfo );
        }

    CleanupStack::PopAndDestroy( &archives );
    CleanupStack::PopAndDestroy( params );
    }
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::WriteItemToFile
 // Writes single trackpoint to GPX file
 // ---------------------------------------------------------------------------
void CGpxConverterAO::WriteItemToFile()
	{
	LOG("CGpxConverterAO::WriteItemToFile ,begin");
	TTime timeStamp;
	
	TPtr8 writePtr = iWriteBuf->Des();
	TPtr formatter = iFormatBuf->Des();
	
	if ( Math::IsNaN(iTempItem.iLatitude) || Math::IsNaN(iTempItem.iLongitude) )
		{
		if ( !iFixLost )
			{
			writePtr.Copy( KTagSegmentEnd );
			iGpxFile.Write( writePtr );
			iFixLost = ETrue;
			}
		}
	else
		{
		if ( iFixLost )
			{
			writePtr.Copy( KTagSegmentStart );
			iGpxFile.Write( writePtr );
			iFixLost = EFalse;
			}
		
		// write single track point
		// coordinates
		formatter.Format( KTagTrkPointStart, iTempItem.iLatitude, iTempItem.iLongitude );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		// elevation
		if ( !Math::IsNaN( iTempItem.iAltitude ))
			{
			formatter.Format( KTagElevation, iTempItem.iAltitude );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
		// course
		if ( !Math::IsNaN( iTempItem.iCourse ))
			{
			formatter.Format( KTagCourse, iTempItem.iCourse );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}

		timeStamp = iTempItem.iTimeStamp;
		TDateTime datetime = timeStamp.DateTime();
		
		formatter.Format( KTagTimeStamp, datetime.Year(), datetime.Month() + 1, datetime.Day() + 1,
				datetime.Hour(), datetime.Minute(), datetime.Second() );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );
		
		if ( !Math::IsNaN( iTempItem.iAltitude ))
			{
			writePtr.Copy( KTagFix3D );
			iGpxFile.Write( writePtr );
			}
		else
			{
			writePtr.Copy( KTagFix2D );
			iGpxFile.Write( writePtr );
			}

		// number of satellites
		formatter.Format( KTagSatellites, iTempItem.iNumSatellites );
		writePtr.Copy( formatter );
		iGpxFile.Write( writePtr );

		// accuracy (hdop, vdop)
		if ( !Math::IsNaN( iTempItem.iHdop ))
			{
			formatter.Format( KTagHdop, iTempItem.iHdop );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
		if ( !Math::IsNaN( iTempItem.iVdop ))
			{
			formatter.Format( KTagVdop, iTempItem.iVdop );
			writePtr.Copy( formatter );
			iGpxFile.Write( writePtr );
			}
	
		// end track point
		writePtr.Copy( KTagTrkPointEnd );
		iGpxFile.Write( writePtr );
		}
	LOG("CGpxConverterAO::WriteItemToFile ,end");
	}
void TAzenqosEngineUtils::MakeTimeStrFile(TTime &time,TDes& str) //str should be at least 19 in length
	{
		TDateTime date = time.DateTime();
		str.Format(KTimeStampFileFormat,date.Year()%2000,date.Month()+1,date.Day()+1,date.Hour(),date.Minute(),date.Second());
	}
// 	print a date and time to log in a readable format:
void LbsTestUtilities::PrintfDateTimeToDebugLog(TTime aTime)
	{
	TDateTime datetime = aTime.DateTime();	
	TESTLOG8(ELogP2,"%d :%d :%d :%d on %d/%d/%d", datetime.Hour(), datetime.Minute(), datetime.Second(), datetime.MicroSecond(), datetime.Day() + 1, datetime.Month() + 1, datetime.Year());	
	}