Changeset 142988 in webkit
- Timestamp:
- Feb 15, 2013 6:05:04 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142987 r142988 1 2013-02-15 Keishi Hattori <keishi@webkit.org> 2 3 PagePopupController.formatMonth should support short month format 4 https://bugs.webkit.org/show_bug.cgi?id=109530 5 6 Reviewed by Kent Tamura. 7 8 PagePopupController.formatMonth should support short month format so we 9 can use it in the new calendar picker. 10 11 Tested by LocaleMacTest::formatMonth. 12 13 * page/PagePopupController.cpp: 14 (WebCore::PagePopupController::formatMonth): Take an extra bool argument to switch to short month format. 15 * page/PagePopupController.h: 16 (PagePopupController): 17 * page/PagePopupController.idl: 18 * platform/text/LocaleICU.cpp: 19 (WebCore::LocaleICU::shortMonthFormat): 20 (WebCore): 21 * platform/text/LocaleICU.h: 22 (LocaleICU): 23 * platform/text/LocaleNone.cpp: 24 (WebCore::shortMonthFormat): 25 (WebCore): 26 * platform/text/PlatformLocale.cpp: 27 (WebCore::DateTimeStringBuilder::visitField): 28 (WebCore::Locale::formatDateTime): 29 * platform/text/PlatformLocale.h: 30 (Locale): 31 * platform/text/mac/LocaleMac.h: 32 (LocaleMac): 33 * platform/text/mac/LocaleMac.mm: 34 (WebCore::LocaleMac::shortMonthFormat): 35 (WebCore): 36 * platform/text/win/LocaleWin.cpp: 37 (WebCore::LocaleWin::shortMonthFormat): Windows doesn't have a short 38 month format so we just replace MMMM with MMM. 39 (WebCore): 40 * platform/text/win/LocaleWin.h: 41 (LocaleWin): 42 1 43 2013-02-15 Keishi Hattori <keishi@webkit.org> 2 44 -
trunk/Source/WebCore/page/PagePopupController.cpp
r142987 r142988 82 82 DateComponents date; 83 83 date.setMonthsSinceEpoch((year - 1970) * 12.0 + zeroBaseMonth); 84 return m_popupClient->locale().formatDateTime(date); 84 return m_popupClient->locale().formatDateTime(date, Locale::FormatTypeMedium); 85 } 86 87 String PagePopupController::formatShortMonth(int year, int zeroBaseMonth) 88 { 89 if (!m_popupClient) 90 return emptyString(); 91 DateComponents date; 92 date.setMonthsSinceEpoch((year - 1970) * 12.0 + zeroBaseMonth); 93 return m_popupClient->locale().formatDateTime(date, Locale::FormatTypeShort); 85 94 } 86 95 #endif -
trunk/Source/WebCore/page/PagePopupController.h
r142987 r142988 50 50 #if ENABLE(CALENDAR_PICKER) 51 51 String formatMonth(int year, int zeroBaseMonth); 52 String formatShortMonth(int year, int zeroBaseMonth); 52 53 #endif 53 54 void clearPagePopupClient(); -
trunk/Source/WebCore/page/PagePopupController.idl
r142987 r142988 38 38 DOMString localizeNumberString(in DOMString numberString); 39 39 [Conditional=CALENDAR_PICKER] DOMString formatMonth(in long year, in long zeroBaseMonth); 40 [Conditional=CALENDAR_PICKER] DOMString formatShortMonth(in long year, in long zeroBaseMonth); 40 41 void histogramEnumeration(DOMString name, long sample, long boundaryValue); 41 42 }; -
trunk/Source/WebCore/platform/text/LocaleICU.cpp
r140308 r142988 356 356 } 357 357 358 String LocaleICU::shortMonthFormat() 359 { 360 if (!m_shortMonthFormat.isNull()) 361 return m_shortMonthFormat; 362 m_shortMonthFormat = getFormatForSkeleton(m_locale.data(), ASCIILiteral("yyyyMMM")); 363 return m_shortMonthFormat; 364 } 365 358 366 String LocaleICU::timeFormat() 359 367 { -
trunk/Source/WebCore/platform/text/LocaleICU.h
r135263 r142988 58 58 virtual String dateFormat() OVERRIDE; 59 59 virtual String monthFormat() OVERRIDE; 60 virtual String shortMonthFormat() OVERRIDE; 60 61 virtual String timeFormat() OVERRIDE; 61 62 virtual String shortTimeFormat() OVERRIDE; … … 104 105 String m_dateFormat; 105 106 String m_monthFormat; 107 String m_shortMonthFormat; 106 108 String m_timeFormatWithSeconds; 107 109 String m_timeFormatWithoutSeconds; -
trunk/Source/WebCore/platform/text/LocaleNone.cpp
r140308 r142988 100 100 } 101 101 102 String shortMonthFormat() 103 { 104 return ASCIILiteral("yyyy-MM"); 105 } 106 102 107 String LocaleNone::timeFormat() 103 108 { -
trunk/Source/WebCore/platform/text/PlatformLocale.cpp
r142122 r142988 100 100 appendNumber(m_date.fullYear(), 4); 101 101 return; 102 case DateTimeFormat::FieldTypeMonth: 102 case DateTimeFormat::FieldTypeMonth: 103 103 if (numberOfPatternCharacters == 3) 104 104 m_builder.append(m_localizer.shortMonthLabels()[m_date.month()]); … … 355 355 break; 356 356 case DateComponents::Month: 357 builder.build( monthFormat());357 builder.build(formatType == FormatTypeShort ? shortMonthFormat() : monthFormat()); 358 358 break; 359 359 case DateComponents::Week: -
trunk/Source/WebCore/platform/text/PlatformLocale.h
r135263 r142988 68 68 virtual String monthFormat() = 0; 69 69 70 // Returns a year-month format using short month lanel in Unicode TR35 LDML. 71 virtual String shortMonthFormat() = 0; 72 70 73 // Returns time format in Unicode TR35 LDML[1] containing hour, minute, and 71 74 // second with optional period(AM/PM), e.g. "h:mm:ss a" … … 129 132 // display to the user. If an implementation doesn't support 130 133 // localized dates the function should return an empty string. 134 // FormatType can be used to specify if you want the short format. 131 135 String formatDateTime(const DateComponents&, FormatType = FormatTypeUnspecified); 132 136 #endif -
trunk/Source/WebCore/platform/text/mac/LocaleMac.h
r135263 r142988 61 61 virtual String dateFormat() OVERRIDE; 62 62 virtual String monthFormat() OVERRIDE; 63 virtual String shortMonthFormat() OVERRIDE; 63 64 virtual String timeFormat() OVERRIDE; 64 65 virtual String shortTimeFormat() OVERRIDE; … … 91 92 String m_dateFormat; 92 93 String m_monthFormat; 94 String m_shortMonthFormat; 93 95 String m_timeFormatWithSeconds; 94 96 String m_timeFormatWithoutSeconds; -
trunk/Source/WebCore/platform/text/mac/LocaleMac.mm
r135263 r142988 205 205 } 206 206 207 String LocaleMac::shortMonthFormat() 208 { 209 if (!m_shortMonthFormat.isNull()) 210 return m_shortMonthFormat; 211 m_shortMonthFormat = [NSDateFormatter dateFormatFromTemplate:@"yyyyMMM" options:0 locale:m_locale.get()]; 212 return m_shortMonthFormat; 213 } 214 207 215 String LocaleMac::timeFormat() 208 216 { -
trunk/Source/WebCore/platform/text/win/LocaleWin.cpp
r141741 r142988 428 428 } 429 429 430 String LocaleWin::shortMonthFormat() 431 { 432 if (m_shortMonthFormat.isNull()) 433 m_shortMonthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)).replace("MMMM", "MMM"); 434 return m_shortMonthFormat; 435 } 436 430 437 String LocaleWin::timeFormat() 431 438 { -
trunk/Source/WebCore/platform/text/win/LocaleWin.h
r135263 r142988 55 55 virtual String dateFormat() OVERRIDE; 56 56 virtual String monthFormat() OVERRIDE; 57 virtual String shortMonthFormat() OVERRIDE; 57 58 virtual String timeFormat() OVERRIDE; 58 59 virtual String shortTimeFormat() OVERRIDE; … … 86 87 String m_dateFormat; 87 88 String m_monthFormat; 89 String m_shortMonthFormat; 88 90 String m_timeFormatWithSeconds; 89 91 String m_timeFormatWithoutSeconds; -
trunk/Source/WebKit/chromium/ChangeLog
r142987 r142988 1 2013-02-15 Keishi Hattori <keishi@webkit.org> 2 3 PagePopupController.formatMonth should support short month format 4 https://bugs.webkit.org/show_bug.cgi?id=109530 5 6 Reviewed by Kent Tamura. 7 8 * tests/LocaleMacTest.cpp: 9 (LocaleMacTest::formatMonth): 10 (TEST_F): 11 1 12 2013-02-15 Keishi Hattori <keishi@webkit.org> 2 13 -
trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp
r134216 r142988 79 79 } 80 80 81 String formatMonth(const String& localeString, const String& isoString )81 String formatMonth(const String& localeString, const String& isoString, bool useShortFormat) 82 82 { 83 83 OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); … … 85 85 unsigned end; 86 86 date.parseMonth(isoString.characters(), isoString.length(), 0, end); 87 return locale->formatDateTime(date );87 return locale->formatDateTime(date, (useShortFormat ? Locale::FormatTypeShort : Locale::FormatTypeMedium)); 88 88 } 89 89 … … 185 185 TEST_F(LocaleMacTest, formatMonth) 186 186 { 187 EXPECT_STREQ("April 2005", formatMonth("en_US", "2005-04").utf8().data()); 188 EXPECT_STREQ("avril 2005", formatMonth("fr_FR", "2005-04").utf8().data()); 189 EXPECT_STREQ("2005\xE5\xB9\xB4" "04\xE6\x9C\x88", formatMonth("ja_JP", "2005-04").utf8().data()); 187 EXPECT_STREQ("April 2005", formatMonth("en_US", "2005-04", false).utf8().data()); 188 EXPECT_STREQ("avril 2005", formatMonth("fr_FR", "2005-04", false).utf8().data()); 189 EXPECT_STREQ("2005\xE5\xB9\xB4" "04\xE6\x9C\x88", formatMonth("ja_JP", "2005-04", false).utf8().data()); 190 191 EXPECT_STREQ("Apr 2005", formatMonth("en_US", "2005-04", true).utf8().data()); 192 EXPECT_STREQ("avr. 2005", formatMonth("fr_FR", "2005-04", true).utf8().data()); 193 EXPECT_STREQ("2005\xE5\xB9\xB4" "04\xE6\x9C\x88", formatMonth("ja_JP", "2005-04", true).utf8().data()); 190 194 } 191 195
Note: See TracChangeset
for help on using the changeset viewer.