const Vector<String>& LocaleWin::timeAMPMLabels() { if (m_timeAMPMLabels.isEmpty()) { m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S1159)); m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S2359)); } return m_timeAMPMLabels; }
void LocaleWin::ensureMonthLabels() { #if ENABLE(DATE_AND_TIME_INPUT_TYPES) if (!m_monthLabels.isEmpty()) return; const LCTYPE types[12] = { LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3, LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6, LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9, LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12, }; m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types)); for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) { m_monthLabels.append(getLocaleInfoString(types[i])); if (m_monthLabels.last().isEmpty()) { m_monthLabels.shrink(0); m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName)); for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthFullName); ++m) m_monthLabels.append(WTF::monthFullName[m]); return; } } #endif }
String LocaleWin::shortMonthFormat() { if (m_shortMonthFormat.isNull()) m_shortMonthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)) .replace("MMMM", "MMM"); return m_shortMonthFormat; }
void LocaleWin::ensureWeekDayShortLabels() { if (!m_weekDayShortLabels.isEmpty()) return; const LCTYPE types[7] = { LOCALE_SABBREVDAYNAME7, // Sunday LOCALE_SABBREVDAYNAME1, // Monday LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, LOCALE_SABBREVDAYNAME6 }; m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(types)); for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) { m_weekDayShortLabels.append(getLocaleInfoString(types[i])); if (m_weekDayShortLabels.last().isEmpty()) { m_weekDayShortLabels.shrink(0); m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::weekdayName)); for (unsigned w = 0; w < WTF_ARRAY_LENGTH(WTF::weekdayName); ++w) { // weekdayName starts with Monday. m_weekDayShortLabels.append(WTF::weekdayName[(w + 6) % 7]); } return; } } }
void LocaleWin::ensureShortMonthLabels() { if (!m_shortMonthLabels.isEmpty()) return; const LCTYPE types[12] = { LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2, LOCALE_SABBREVMONTHNAME3, LOCALE_SABBREVMONTHNAME4, LOCALE_SABBREVMONTHNAME5, LOCALE_SABBREVMONTHNAME6, LOCALE_SABBREVMONTHNAME7, LOCALE_SABBREVMONTHNAME8, LOCALE_SABBREVMONTHNAME9, LOCALE_SABBREVMONTHNAME10, LOCALE_SABBREVMONTHNAME11, LOCALE_SABBREVMONTHNAME12, }; m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types)); for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) { m_shortMonthLabels.append(getLocaleInfoString(types[i])); if (m_shortMonthLabels.last().isEmpty()) { m_shortMonthLabels.shrink(0); m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName)); for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthName); ++m) m_shortMonthLabels.append(WTF::monthName[m]); return; } } }
String LocaleWin::monthFormat() { if (!m_monthFormat.isNull()) return m_monthFormat; m_monthFormat = convertWindowsDateFormatToLDML(parseDateFormat(getLocaleInfoString(LOCALE_SYEARMONTH))); return m_monthFormat; }
String LocaleWin::shortTimeFormat() { if (!m_timeFormatWithoutSeconds.isNull()) return m_timeFormatWithoutSeconds; String format = getLocaleInfoString(LOCALE_SSHORTTIME); // Vista or older Windows doesn't support LOCALE_SSHORTTIME. if (format.isEmpty()) { format = getLocaleInfoString(LOCALE_STIMEFORMAT); StringBuilder builder; builder.append(getLocaleInfoString(LOCALE_STIME)); builder.append("ss"); size_t pos = format.reverseFind(builder.toString()); if (pos != kNotFound) format.remove(pos, builder.length()); } m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format); return m_timeFormatWithoutSeconds; }
void LocaleWin::initializeLocaleData() { if (m_didInitializeNumberData) return; Vector<String, DecimalSymbolsSize> symbols; enum DigitSubstitution { DigitSubstitutionContext = 0, DigitSubstitution0to9 = 1, DigitSubstitutionNative = 2, }; DWORD digitSubstitution = DigitSubstitution0to9; getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, digitSubstitution); if (digitSubstitution == DigitSubstitution0to9) { symbols.append("0"); symbols.append("1"); symbols.append("2"); symbols.append("3"); symbols.append("4"); symbols.append("5"); symbols.append("6"); symbols.append("7"); symbols.append("8"); symbols.append("9"); } else { String digits = getLocaleInfoString(LOCALE_SNATIVEDIGITS); ASSERT(digits.length() >= 10); for (unsigned i = 0; i < 10; ++i) symbols.append(digits.substring(i, 1)); } ASSERT(symbols.size() == DecimalSeparatorIndex); symbols.append(getLocaleInfoString(LOCALE_SDECIMAL)); ASSERT(symbols.size() == GroupSeparatorIndex); symbols.append(getLocaleInfoString(LOCALE_STHOUSAND)); ASSERT(symbols.size() == DecimalSymbolsSize); String negativeSign = getLocaleInfoString(LOCALE_SNEGATIVESIGN); enum NegativeFormat { NegativeFormatParenthesis = 0, NegativeFormatSignPrefix = 1, NegativeFormatSignSpacePrefix = 2, NegativeFormatSignSuffix = 3, NegativeFormatSpaceSignSuffix = 4, }; DWORD negativeFormat = NegativeFormatSignPrefix; getLocaleInfo(LOCALE_INEGNUMBER, negativeFormat); String negativePrefix = emptyString(); String negativeSuffix = emptyString(); switch (negativeFormat) { case NegativeFormatParenthesis: negativePrefix = "("; negativeSuffix = ")"; break; case NegativeFormatSignSpacePrefix: negativePrefix = negativeSign + " "; break; case NegativeFormatSignSuffix: negativeSuffix = negativeSign; break; case NegativeFormatSpaceSignSuffix: negativeSuffix = " " + negativeSign; break; case NegativeFormatSignPrefix: // Fall through. default: negativePrefix = negativeSign; break; } m_didInitializeNumberData = true; setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativeSuffix); }
String LocaleWin::timeFormat() { if (m_timeFormatWithSeconds.isNull()) m_timeFormatWithSeconds = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_STIMEFORMAT)); return m_timeFormatWithSeconds; }
String LocaleWin::monthFormat() { if (m_monthFormat.isNull()) m_monthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)); return m_monthFormat; }
String LocaleWin::dateFormat() { if (m_dateFormat.isNull()) m_dateFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SSHORTDATE)); return m_dateFormat; }
String LocaleWin::timeFormatText() { if (m_timeFormatText.isEmpty()) m_timeFormatText = convertWindowsTimeFormatToLDML(getLocaleInfoString(LOCALE_STIMEFORMAT)); return m_timeFormatText; }
void LocaleWin::ensureShortDateTokens() { if (!m_shortDateTokens.isEmpty()) return; m_shortDateTokens = parseDateFormat(getLocaleInfoString(LOCALE_SSHORTDATE)); }