Bug 1512123 - Make timepicker recognize local characters representing the day period. r=philipp DONTBUILD
authorMakeMyDay <makemyday@gmx-topmail.de>
Fri, 29 Mar 2019 20:03:41 +0100
changeset 35824 75267aa625a2ee5cb0581271dec6871c0b3b7fc7
parent 35823 92831637a3fa267d7df0b98c8604b78b6872efc2
child 35825 4e10b0b8aa3fee9d57b986878c47306dea5d2b70
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersphilipp
bugs1512123
Bug 1512123 - Make timepicker recognize local characters representing the day period. r=philipp DONTBUILD
calendar/resources/content/datetimepickers/datetimepickers.js
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -1406,22 +1406,20 @@
      * or may be omitted as in 151200.
      */
     function initTimeFormat() {
         // probe the Time format
         ampmIndex = null;
         // Digits         HR           sep          MIN         sep          SEC         sep
         //   Index:       2            3            4           5            6           7
         let digitsExpr = "(\\d?\\d)\\s?(\\D)?\\s?(?:(\\d\\d)\\s?(\\D)?\\s?(?:(\\d\\d)\\s?(\\D)?\\s?)?)?";
-        // any letters or '.': non-digit alphanumeric, period (a.m.), or space (P M)
-        let anyAmPmExpr = "(?:[^\\d\\W]|[. ])+";
         // digitsExpr has 6 captures, so index of first ampmExpr is 1, of last is 8.
-        let probeTimeRegExp =
-            new RegExp("^(" + anyAmPmExpr + ")?\\s?" + digitsExpr + "(" + anyAmPmExpr + ")?\\s*$");
-        const PRE_INDEX = 1, HR_INDEX = 2, MIN_INDEX = 4, SEC_INDEX = 6, POST_INDEX = 8; // eslint-disable-line no-unused-vars
+        let probeTimeRegExp = new RegExp("^\\s*(\\D*)\\s?" + digitsExpr + "\\s?(\\D*)\\s*$");
+        // eslint-disable-next-line no-unused-vars
+        const PRE_INDEX = 1, HR_INDEX = 2, MIN_INDEX = 4, SEC_INDEX = 6, POST_INDEX = 8;
         let amProbeTime = new Date(2000, 0, 1, 6, 12, 34);
         let pmProbeTime = new Date(2000, 0, 1, 18, 12, 34);
         let formatter = new Services.intl.DateTimeFormat(undefined, { timeStyle: "short" });
         let amProbeString = formatter.format(amProbeTime);
         let pmProbeString = formatter.format(pmProbeTime);
         let amFormatExpr = null, pmFormatExpr = null;
         if (amProbeString != pmProbeString) {
             let amProbeArray = probeTimeRegExp.exec(amProbeString);