Bug 1416618 - Cannot show short date format (yy/MM/dd'('ddd')') correctly. r?jfkthame
On Windows 7, there is yy/mm/dd'('ddd')' as short date format of Japanese.
When selecting this, ddd isn't converted to day of the week correctly.
FindInReadable will update start position iterator even if not found. So when
using FindInReadable again, we have to reset start position iterator.
MozReview-Commit-ID: AoS1Txq3Twc
--- a/intl/locale/windows/OSPreferences_win.cpp
+++ b/intl/locale/windows/OSPreferences_win.cpp
@@ -171,18 +171,21 @@ OSPreferences::ReadDateTimePattern(DateT
// but in a CLDR/ICU-style pattern these should be "EEE" and "EEEE".
// http://userguide.icu-project.org/formatparse/datetime
// So we fix that up here.
nsAString::const_iterator start, pos, end;
start = str->BeginReading(pos);
str->EndReading(end);
if (FindInReadable(NS_LITERAL_STRING("dddd"), pos, end)) {
str->ReplaceLiteral(pos - start, 4, u"EEEE");
- } else if (FindInReadable(NS_LITERAL_STRING("ddd"), pos, end)) {
- str->ReplaceLiteral(pos - start, 3, u"EEE");
+ } else {
+ pos = start;
+ if (FindInReadable(NS_LITERAL_STRING("ddd"), pos, end)) {
+ str->ReplaceLiteral(pos - start, 3, u"EEE");
+ }
}
// Also, Windows uses lowercase "g" or "gg" for era, but ICU wants uppercase "G"
// (it would interpret "g" as "modified Julian day"!). So fix that.
int32_t index = str->FindChar('g');
if (index >= 0) {
str->Replace(index, 1, 'G');
// If it was a double "gg", just drop the second one.