Bug 1517569 - Ignore spacing around time separators when parsing times in timepicker. r=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Sun, 17 Mar 2019 15:15:54 +0100
changeset 35823 92831637a3fa267d7df0b98c8604b78b6872efc2
parent 35822 f6d100d63838d747a56735854aecb78cc415acda
child 35824 75267aa625a2ee5cb0581271dec6871c0b3b7fc7
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersphilipp
bugs1517569
Bug 1517569 - Ignore spacing around time separators when parsing times in timepicker. r=philipp
calendar/resources/content/datetimepickers/datetimepickers.js
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -1403,19 +1403,19 @@
      * mm and ss are is minutes and seconds digits, with leading 0.
      * tt is localized AM or PM string.
      * ':' may be ':' or a units marker such as 'h', 'm', or 's' in  15h12m00s
      * 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)(\\D)?(?:(\\d\\d)(\\D)?(?:(\\d\\d)(\\D)?)?)?";
+        // 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 amProbeTime = new Date(2000, 0, 1, 6, 12, 34);
         let pmProbeTime = new Date(2000, 0, 1, 18, 12, 34);