Esempio n. 1
0
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;
	
	}
/*!

 */
void SettingsUtility::setDateFormat(const QString &format)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATEFORMAT_ENTRY );
	TLocale locale;
	int index;

	for (index = 0; index < mDisplayDateFormatList.count(); ++index) {
		if (format == mDisplayDateFormatList.at(index)) {
			break;
		}
	}

	switch (index) {
		case 0:
			locale.SetDateFormat(EDateEuropean);
			break;
		case 1:
			locale.SetDateFormat(EDateAmerican);
			break;
		case 2:
			locale.SetDateFormat(EDateJapanese);
			break;
		default:
			//Nothing to do.
			break;
	}

	locale.Set();
	OstTraceFunctionExit0( SETTINGSUTILITY_SETDATEFORMAT_EXIT );
}
/*!
	Sets the start of week value selected by the user.

	\param index The index of the selected value.
 */
void SettingsUtility::setStartOfWeek(int index)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETSTARTOFWEEK_ENTRY );
	TLocale locale;
	TDay day = (TDay)index;
	locale.SetStartOfWeek(day);
	locale.Set();
	OstTraceFunctionExit0( SETTINGSUTILITY_SETSTARTOFWEEK_EXIT );
}
/*!

 */
void SettingsUtility::setDateSeparator(const QString &separator)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETDATESEPARATOR_ENTRY );
	TLocale locale;
	locale.SetDateSeparator(
			TChar(separator.unicode()->unicode()), 1);
	locale.SetDateSeparator(
			TChar(separator.unicode()->unicode()), 2);
	locale.Set();
	OstTraceFunctionExit0( SETTINGSUTILITY_SETDATESEPARATOR_EXIT );
}
/*!

 */
void SettingsUtility::setTimeSeparator(const QString &separator)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETTIMESEPARATOR_ENTRY );
	if (mTimeSeparatorList.contains(separator)) {
	    TLocale locale;

		locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 1);
		locale.SetTimeSeparator(TChar(separator.unicode()->unicode()), 2);

		locale.Set();
    }
	OstTraceFunctionExit0( SETTINGSUTILITY_SETTIMESEPARATOR_EXIT );
}
Esempio n. 6
0
// Regression testcode for EDNJKAA-4WLDAY
// "Cannot synchronise Outlook contacts with German device"
//
// Tests filtering under the following conditions
// Time & date separator '.'
// Time separator ':', date separator '.'
// Time & date separator ':'
// Time separator '.', date separator ':'
//
LOCAL_C void TestFilterLocalesL()
{
    SimpleFilterTestL();
    NonDateBasedFilterTest();
    TInt i=0;
    TLocale example;
    example.SetDateFormat(EDateEuropean);
    for (i=0; i<4; i++)
    {
        example.SetTimeSeparator(TChar('.'),i);
        example.SetDateSeparator(TChar('.'),i);
    }
    example.Set();
    SimpleFilterTestL();

    example.SetDateFormat(EDateAmerican);
    for (i=0; i<4; i++)
    {
        example.SetTimeSeparator(TChar(':'),i);
    }
    example.Set();
    SimpleFilterTestL();

    example.SetDateFormat(EDateJapanese);
    for (i=0; i<4; i++)
    {
        example.SetDateSeparator(TChar(':'),i);
    }
    example.Set();
    SimpleFilterTestL();

    for (i=0; i<4; i++)
    {
        example.SetTimeSeparator(TChar('.'),i);
    }
    example.Set();
    SimpleFilterTestL();
}
/*!

 */
void SettingsUtility::setTimeFormat(const QString& format)
{
	OstTraceFunctionEntry0( SETTINGSUTILITY_SETTIMEFORMAT_ENTRY );
	TLocale locale;

	if (format == mTimeFormatList.at(0)) {
		locale.SetTimeFormat(ETime24);
	} else if (format == mTimeFormatList.at(1)) {
		locale.SetTimeFormat(ETime12);
	} else {
		// Nothing to do.
	}
	locale.Set();
	OstTraceFunctionExit0( SETTINGSUTILITY_SETTIMEFORMAT_EXIT );
}
Esempio n. 8
0
/**
Sets up the system-wide locale and language downgrade path for the new locale model.
*/
void REComLanguagePluginTest::SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3])
    {
    TLocale locale;
    TExtendedLocale extendedLocale;
    TInt loadval = 0;

    extendedLocale.LoadSystemSettings();
    loadval = extendedLocale.LoadLocale(aLanguage,aReg,aColl);
    TEST(loadval==KErrNone, __LINE__);
    extendedLocale.SaveSystemSettings();

    locale.SetLanguageDowngrade(0, aLang[0]);
    locale.SetLanguageDowngrade(1, aLang[1]);
    locale.SetLanguageDowngrade(2, aLang[2]);
    locale.Set();
    }
Esempio n. 9
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-CT-0883
@SYMTestCaseDesc	    Tests for CLogClient::ClearLog() function
@SYMTestPriority 	    High
@SYMTestActions  	    Change locale settings,call up ClearLog and try to retrieve event,test for count of number of events in the view.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void TestClearLog2L(CLogClient& aClient)
	{
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0883 "));
	CLogEvent* event = CLogEvent::NewL();
	CleanupStack::PushL(event);
	event->SetEventType(KLogCallEventTypeUid);

	CTestActive* active = new(ELeave)CTestActive();
	CleanupStack::PushL(active);

	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
	CleanupStack::PushL(view);

	// change Locale
	TLocale locale;
	locale.SetCountryCode(47);//Norway
	locale.SetDateFormat(EDateEuropean);
	locale.SetTimeFormat(ETime12);
	for (int i=0; i<4; i++)
         {
         locale.SetTimeSeparator(TChar('.'),i);
         locale.SetDateSeparator(TChar(':'),i);
         }
	locale.Set();

	// change the log duration settings to 1 day  
	TLogConfig config;
	active->StartL();
	aClient.GetConfig(config, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNone);

	config.iMaxLogSize = KTestEventAge * 2;
	config.iMaxEventAge = 86400;
	active->StartL();
	aClient.ChangeConfig(config, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNone);

	// add a call event
	active->StartL();
	aClient.AddEvent(*event, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNone);
	User::After(1000000);
	TTime now;
	now.HomeTime();	
	event->SetTime(now);
	active->StartL();
	aClient.ChangeEvent(*event, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNone);

	// forward two days
	now+=(TTimeIntervalDays )2;
	User::SetHomeTime(now);
		
	active->StartL();
	aClient.ClearLog(now, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNone);

	// try to retrieve event
	active->StartL();
	aClient.GetEvent(*event, active->iStatus);
	CActiveScheduler::Start();
	TEST2(active->iStatus.Int(), KErrNotFound);;

	TEST(view->CountL() == 0);

	CleanupStack::PopAndDestroy(3); // view, active, event
	}