Bug 1521454 - Avoid exception due to bad locale code when appending [-u]-ca-gregory-nu-latn. r=zibi
authorJorg K <jorgk@jorgk.com>
Fri, 25 Jan 2019 22:54:32 +0100
changeset 33452 0396f1f1c7a7
parent 33451 bfa78ee4ab64
child 33453 be6ed62ca1ec
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszibi
bugs1521454
Bug 1521454 - Avoid exception due to bad locale code when appending [-u]-ca-gregory-nu-latn. r=zibi
common/bindings/datetimepicker.xml
--- a/common/bindings/datetimepicker.xml
+++ b/common/bindings/datetimepicker.xml
@@ -485,17 +485,22 @@
         <body>
           <![CDATA[
             this.hourField = this._fieldOne;
             this.minuteField = this._fieldTwo;
             this.secondField = this._fieldThree;
 
             var numberOrder = /^(\D*)\s*(\d+)(\D*)(\d+)(\D*)(\d+)\s*(\D*)$/;
 
-            var locale = Services.locale.regionalPrefsLocales[0] + "-u-ca-gregory-nu-latn";
+            // XXX TODO: The following hack should be fixed once Intl.Locale arrives in bug 1433303.
+            var locale = Services.locale.regionalPrefsLocales[0];
+            if (locale.includes("-u-"))
+              locale += "-ca-gregory-nu-latn";
+            else
+              locale += "-u-ca-gregory-nu-latn";
             var dtf = new Services.intl.DateTimeFormat(locale, { timeStyle: "long" });
 
             var pmTime = dtf.format(new Date(2000, 0, 1, 16, 7, 9));
             var numberFields = pmTime.match(numberOrder);
             if (numberFields) {
               this._separatorFirst.value = numberFields[3];
               this._separatorSecond.value = numberFields[5];
               if (Number(numberFields[2]) > 12)