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 34306 0396f1f1c7a71b39d0066af121cc4afca6d84b6c
parent 34305 bfa78ee4ab64803a3a85dd664e1335d525644001
child 34307 be6ed62ca1ec58c7ca3a2135a5560b6e70583ceb
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
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)