Add Localizer::monthFormat and implementations
https://bugs.webkit.org/show_bug.cgi?id=99704
Reviewed by Kentaro Hara.
Source/WebCore:
Localizer::monthFormat will be used for constructing input[type=month] UI.
Tests: Add unit tests to Source/WebKit/chromium/tests/.
* platform/text/Localizer.h:
(Localizer): Declare pure virtual monthFormat function.
* platform/text/LocaleNone.cpp:
(LocaleNone): Declare monthFormat.
(WebCore::LocaleNone::monthFormat):
Added. Always reutrns an ISO-8601 format, "yyyy-MM"
* platform/text/LocaleICU.h:
(LocaleICU): Declare monthFormat.
* platform/text/LocaleICU.cpp:
(WebCore::getFormatForSkeleton):
A helper to get a format for the specified skeleton.
The overflow-allocalte-try-again pattern is similar to
LocaleICU::decimalSymbol and LocaleICU::decimalTextAttribute.
(WebCore::LocaleICU::monthFormat):
Added. Calls getFormatForSkeleton with "yyyyMMM".
* platform/text/mac/LocaleMac.h:
(LocaleMac): Declare monthFormat.
* platform/text/mac/LocaleMac.mm:
(WebCore::LocaleMac::monthFormat):
Added. Calls NSDateFormatter::dateFormatFromTemplate with "yyyyMMM".
* platform/text/LocaleWin.h:
(LocaleWin): Declare monthFormat.
* platform/text/LocaleWin.cpp:
(WebCore::LocaleWin::monthFormat):
Get a format by LOCALE_SYEARMONTH, and convert it to an LDML format.
Source/WebKit/chromium:
* tests/LocaleMacTest.cpp:
(LocaleMacTest::monthFormat): A helper function.
(TEST_F): Added some tests.
* tests/LocaleWinTest.cpp:
(LocaleWinTest::monthFormat): A helper function.
(TEST_F): Added some tests.
* tests/LocalizedDateICUTest.cpp:
(LocalizedDateICUTest::monthFormat): A helper function.
(TEST_F): Added some tests.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/text/LocaleNone.cpp b/Source/WebCore/platform/text/LocaleNone.cpp
index 0ddaf30..6b4465c 100644
--- a/Source/WebCore/platform/text/LocaleNone.cpp
+++ b/Source/WebCore/platform/text/LocaleNone.cpp
@@ -42,6 +42,7 @@
#endif
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
virtual String dateFormat() OVERRIDE;
+ virtual String monthFormat() OVERRIDE;
#endif
};
@@ -80,6 +81,11 @@
{
return ASCIILiteral("dd/MM/yyyyy");
}
+
+String LocaleNone::monthFormat()
+{
+ return ASCIILiteral("yyyy-MM");
+}
#endif
} // namespace WebCore