[tbb-commits] [tor-browser/tor-browser-84.0-10.0-1] Bug 1681251 - Return AUTF8String from GetDateTimePattern in mozIOSPreferences; r=zbraniecki, a=RyanVM

sysrqb at torproject.org sysrqb at torproject.org
Fri Dec 11 18:25:48 UTC 2020


commit 63e3dc6e23e7075570600005cf5400b3cc41640e
Author: Dan Minor <dminor at mozilla.com>
Date:   Wed Dec 9 03:16:23 2020 +0000

    Bug 1681251 - Return AUTF8String from GetDateTimePattern in mozIOSPreferences; r=zbraniecki, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D99162
---
 intl/locale/mozIOSPreferences.idl               |  6 +++---
 toolkit/components/mozintl/test/test_mozintl.js | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/intl/locale/mozIOSPreferences.idl b/intl/locale/mozIOSPreferences.idl
index b18df3fbc654..f3e1c124408d 100644
--- a/intl/locale/mozIOSPreferences.idl
+++ b/intl/locale/mozIOSPreferences.idl
@@ -89,7 +89,7 @@ interface mozIOSPreferences : nsISupports
    * handle all scenarios, including with cases where we fail to retrieve
    * anything from the OS, here.
    */
-  ACString getDateTimePattern(in long timeFormatStyle,
-                              in long dateFormatStyle,
-                              [optional] in ACString locale);
+  AUTF8String getDateTimePattern(in long timeFormatStyle,
+                                 in long dateFormatStyle,
+                                 [optional] in ACString locale);
 };
diff --git a/toolkit/components/mozintl/test/test_mozintl.js b/toolkit/components/mozintl/test/test_mozintl.js
index ba1fb498e161..3f9e66b54fa1 100644
--- a/toolkit/components/mozintl/test/test_mozintl.js
+++ b/toolkit/components/mozintl/test/test_mozintl.js
@@ -8,6 +8,7 @@ function run_test() {
   test_methods_calling();
   test_constructors();
   test_rtf_formatBestUnit();
+  test_datetimeformat();
 
   ok(true);
 }
@@ -162,3 +163,18 @@ function test_rtf_formatBestUnit() {
     testRTFBestUnit(anchor, "2098-01-02 18:30", "in 82 years");
   }
 }
+
+function test_datetimeformat() {
+  Services.prefs.setStringPref(
+    "intl.date_time.pattern_override.date_long",
+    "yyyy年M月d日"
+  );
+
+  let formatted = new Services.intl.DateTimeFormat("ja", {
+    dateStyle: "long",
+  }).format(new Date("2020-12-08 21:00:05"));
+
+  equal(formatted, "2020年12月8日");
+
+  Services.prefs.clearUserPref("intl.date_time.pattern_override.date_long");
+}





More information about the tbb-commits mailing list