Bug 1416618 - Cannot show short date format (yy/MM/dd'('ddd')') correctly. r=jfkthame
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 14 Nov 2017 10:53:51 +0900
changeset 436398 26b0f3f9fca10fc215d2c597050e20ed21cad510
parent 436397 9ccc25047469c3ccfaaa3a13c5e08595b3f31065
child 436399 89af2bd84c001d94d22cf070b7acee7f13e4453d
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersjfkthame
bugs1416618
milestone59.0a1
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
intl/locale/windows/OSPreferences_win.cpp
--- 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.