Bug 1416618 - Cannot show short date format (yy/MM/dd'('ddd')') correctly. r?jfkthame draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 14 Nov 2017 10:53:51 +0900
changeset 697454 002c76c2e3317890f71144f32f039c245d644680
parent 697453 e1d7427787f7a26983c92ea1a1ac99eb863edd6c
child 740125 715a4beed82e55c9fc4a9e4849a19b6658952c2b
push id89007
push userbmo:m_kato@ga2.so-net.ne.jp
push dateTue, 14 Nov 2017 01:59:22 +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.