Bug 1416618 - Cannot show short date format (yy/MM/dd'('ddd')') correctly. r=jfkthame, a=gchang
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 14 Nov 2017 10:53:51 +0900
changeset 444791 125c6999fe56a302bbeb5fd5c2d960c56fac3ec8
parent 444790 c78d02a2b591e322dfb8430d49d5d76d8848e5ed
child 444792 ef08956b714db2dd288751c1dc9f65fd5cbbeaad
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame, gchang
bugs1416618
milestone58.0
Bug 1416618 - Cannot show short date format (yy/MM/dd'('ddd')') correctly. r=jfkthame, a=gchang 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.