void testUK(const TLocale& aLocale) { //#ifdef __WINS__ test(aLocale.CountryCode()==44); test(aLocale.DateFormat()==EDateEuropean); test(aLocale.TimeFormat()==ETime12); test(aLocale.CurrencySymbolPosition()==ELocaleBefore); test(aLocale.CurrencySpaceBetween()==FALSE); test(aLocale.CurrencyDecimalPlaces()==2); test(aLocale.CurrencyNegativeInBrackets()==EFalse); test(aLocale.CurrencyTriadsAllowed()==TRUE); test(aLocale.ThousandsSeparator()==','); test(aLocale.DecimalSeparator()=='.'); test(aLocale.DateSeparator(0)==0); test(aLocale.DateSeparator(1)=='/'); test(aLocale.DateSeparator(2)=='/'); test(aLocale.DateSeparator(3)==0); test(aLocale.TimeSeparator(0)==0); test(aLocale.TimeSeparator(1)==':'); test(aLocale.TimeSeparator(2)==':'); test(aLocale.TimeSeparator(3)==0); test(aLocale.AmPmSymbolPosition()==TRUE); test(aLocale.AmPmSpaceBetween()==TRUE); test(aLocale.HomeDaylightSavingZone()==EDstEuropean); test(aLocale.WorkDays()==0x1f); test(aLocale.StartOfWeek()==EMonday); test(aLocale.ClockFormat()==EClockAnalog); test(aLocale.UnitsGeneral()==EUnitsImperial); test(aLocale.UnitsDistanceShort()==EUnitsImperial); test(aLocale.UnitsDistanceLong()==EUnitsImperial); //#endif }
void testUS(const TLocale& aLocale) { test.Printf(_L("Test US\n")); test(aLocale.CountryCode()==1); test(aLocale.DateFormat()==EDateAmerican); test(aLocale.TimeFormat()==ETime12); test(aLocale.CurrencySymbolPosition()==ELocaleBefore); test(aLocale.CurrencySpaceBetween()==FALSE); test(aLocale.CurrencyDecimalPlaces()==2); test(aLocale.CurrencyNegativeInBrackets()==EFalse); test(aLocale.CurrencyTriadsAllowed()==TRUE); test(aLocale.ThousandsSeparator()==','); test(aLocale.DecimalSeparator()=='.'); test(aLocale.DateSeparator(0)==0); test(aLocale.DateSeparator(1)=='/'); test(aLocale.DateSeparator(2)=='/'); test(aLocale.DateSeparator(3)==0); test(aLocale.TimeSeparator(0)==0); test(aLocale.TimeSeparator(1)==':'); test(aLocale.TimeSeparator(2)==':'); test(aLocale.TimeSeparator(3)==0); test(aLocale.AmPmSymbolPosition()==TRUE); test(aLocale.AmPmSpaceBetween()==TRUE); test(aLocale.HomeDaylightSavingZone()==EDstNorthern); test(aLocale.WorkDays()==0x1f); test(aLocale.StartOfWeek()==ESunday); test(aLocale.ClockFormat()==EClockAnalog); test(aLocale.UnitsGeneral()==EUnitsImperial); test(aLocale.UnitsDistanceShort()==EUnitsImperial); test(aLocale.UnitsDistanceLong()==EUnitsImperial); }
/*! */ int SettingsUtility::dateFormat(QStringList &format) { OstTraceFunctionEntry0( SETTINGSUTILITY_DATEFORMAT_ENTRY ); TLocale locale; int index = -1; switch (locale.DateFormat()) { case EDateEuropean: index = 0; break; case EDateAmerican: index = 1; break; case EDateJapanese: index = 2; break; default: // Nothing yet. break; } format = mDisplayDateFormatList; OstTraceFunctionExit0( SETTINGSUTILITY_DATEFORMAT_EXIT ); return index; }
static void initialiseDateFormat() { if(dateFormat.Length()) return; TLocale locale; //Separator 1 is used between 1st and 2nd components of the date //Separator 2 is used between 2nd and 3rd components of the date //Usually they are the same, but they are allowed to be different TChar s1 = locale.DateSeparator(1); TChar s2 = locale.DateSeparator(2); dateFormat=KLocaleIndependent; switch(locale.DateFormat()) { case EDateAmerican: dateFormat.Append(KMonth); dateFormat.Append(s1); dateFormat.Append(KDay); dateFormat.Append(s2); dateFormat.Append(KYear); break; case EDateEuropean: dateFormat.Append(KDay); dateFormat.Append(s1); dateFormat.Append(KMonth); dateFormat.Append(s2); dateFormat.Append(KYear); break; case EDateJapanese: default: //it's closest to ISO format dateFormat.Append(KYear); dateFormat.Append(s1); dateFormat.Append(KMonth); dateFormat.Append(s2); dateFormat.Append(KDay); break; } #ifdef _DEBUG RDebug::Print(_L("Date Format \"%S\""), &dateFormat); #endif }
/*! Returns a Qt version of the given \a sys_fmt Symbian locale format string. */ static QString s60ToQtFormat(const QString &sys_fmt) { TLocale *locale = _s60Locale.GetLocale(); QString result; QString other; QString qtformatchars = QString::fromLatin1("adhmsyzAHM"); QChar c; int i = 0; bool open_escape = false; bool abbrev_next = false; bool locale_indep_ordering = false; bool minus_mode = false; bool plus_mode = false; bool n_mode = false; TTimeFormat tf = locale->TimeFormat(); while (i < sys_fmt.size()) { c = sys_fmt.at(i); // let formatting thru if (c.unicode() == '%') { // if we have gathered string, concat it if (!other.isEmpty()) { result += other; other.clear(); } // if we have open escape, end it if (open_escape) { result += QLatin1Char('\''); open_escape = false; } ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); // process specials abbrev_next = c.unicode() == '*'; plus_mode = c.unicode() == '+'; minus_mode = c.unicode() == '-'; if (abbrev_next || plus_mode || minus_mode) { ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (plus_mode || minus_mode) { // break on undefined plus/minus mode if (c.unicode() != 'A' && c.unicode() != 'B') break; } } switch (c.unicode()) { case 'F': { // locale indep mode on locale_indep_ordering = true; break; } case '/': { // date sep 0-3 ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit() && c.digitValue() <= 3) { TChar s = locale->DateSeparator(c.digitValue()); TUint val = s; // some indexes return zero for empty if (val > 0) result += QChar(val); } break; } case 'D': { if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("dd"); else result += QLatin1Char('d'); break; } case 'M': { if (!locale_indep_ordering) break; if (!n_mode) { if (!abbrev_next) result += QLatin1String("MM"); else result += QLatin1String("M"); } else { if (!abbrev_next) result += QLatin1String("MMMM"); else result += QLatin1String("MMM"); } break; } case 'N': { n_mode = true; if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("MMMM"); else result += QLatin1String("MMM"); break; } case 'Y': { if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("yyyy"); else result += QLatin1String("yy"); break; } case 'E': { if (!abbrev_next) result += QLatin1String("dddd"); else result += QLatin1String("ddd"); break; } case ':': { // timesep 0-3 ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit() && c.digitValue() <= 3) { TChar s = locale->TimeSeparator(c.digitValue()); TUint val = s; // some indexes return zero for empty if (val > 0) result += QChar(val); } break; } case 'J': { if (tf == ETime24 && !abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; } case 'H': { if (!abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; } case 'I': { result += QLatin1Char('h'); break; } case 'T': { if (!abbrev_next) result += QLatin1String("mm"); else result += QLatin1Char('m'); break; } case 'S': { if (!abbrev_next) result += QLatin1String("ss"); else result += QLatin1Char('s'); break; } case 'B': { // only done for 12h clock if (tf == ETime24) break; } // fallthru to A case 'A': { // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic TAmPmName ampm = TAmPmName(); TChar first(ampm[0]); QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap"); int pos = locale->AmPmSymbolPosition(); if ((minus_mode && pos != ELocaleBefore) || (plus_mode && pos != ELocaleAfter)) break; if (!abbrev_next && locale->AmPmSpaceBetween()) { if (pos == ELocaleBefore) qtampm.append(QLatin1Char(' ')); else qtampm.prepend(QLatin1Char(' ')); } result += qtampm; } break; case '.': { // decimal sep TChar s = locale->DecimalSeparator(); TUint val = s; if (val > 0) result += QChar(val); } break; case 'C': { // six digits in s60, three digits in qt if (!abbrev_next) { result += QLatin1String("zzz"); } else { // next char is number from 0-6, how many digits to display ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit()) { // try to match wanted digits QChar val(c.digitValue()); if (val >= 3) { result += QLatin1String("zzz"); } else if (val > 0) { result += QLatin1Char('z'); } } } break; } // these cases fallthru case '1': case '2': case '3': case '4': case '5': { // shouldn't parse these with %F if (locale_indep_ordering) break; TDateFormat df = locale->DateFormat(); const char **locale_dep; switch (df) { default: // fallthru to american case EDateAmerican: locale_dep = us_locale_dep; break; case EDateEuropean: locale_dep = eu_locale_dep; break; case EDateJapanese: locale_dep = jp_locale_dep; break; } int offset = 0; if (abbrev_next) offset += 5; if (n_mode) offset += 10; result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]); break; } case '%': // fallthru percent { // any junk gets copied as is } default: { result += c; break; } case 'Z': // Qt doesn't support these :( case 'X': case 'W': { break; } } } else { // double any single quotes, don't begin escape if (c.unicode() == '\'') { // end open escape if (open_escape) { result += other; other.clear(); result += QLatin1Char('\''); open_escape = false; } other += c; } // gather chars and escape them in one go if any format chars are found if (!open_escape && qtformatchars.indexOf(c) != -1) { result += QLatin1Char('\''); open_escape = true; } other += c; } ++i; } if (!other.isEmpty()) result += other; if (open_escape) result += QLatin1Char('\''); return result; }