]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Moving regexes to global closure
authorTim Wood <washwithcare@gmail.com>
Wed, 28 Dec 2011 18:50:28 +0000 (10:50 -0800)
committerTim Wood <washwithcare@gmail.com>
Wed, 28 Dec 2011 18:50:28 +0000 (10:50 -0800)
moment.js

index 56cf1482f1e362fec146e8d5126f458111056d59..af2ecae8402ca7be484b07eb6792d0d976af586c 100644 (file)
--- a/moment.js
+++ b/moment.js
         hasModule = (typeof module !== 'undefined'),
         paramsToParse = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'),
         i,
+        charactersToReplace = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,
+        nonuppercaseLetters = /[^A-Z]/g,
+        timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
+        tokenCharacters = /(\\)?(MM?M?M?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g,
+        inputCharacters = /(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi,
+        timezoneParseRegex = /([\+\-]|\d\d)/gi,
         VERSION = "1.2.0",
         shortcuts = 'Month|Date|Hours|Minutes|Seconds|Milliseconds'.split('|');
 
@@ -80,9 +86,6 @@
             currentMinutes = date.getMinutes(),
             currentSeconds = date.getSeconds(),
             currentZone = date.getTimezoneOffset(),
-            charactersToReplace = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,
-            nonuppercaseLetters = /[^A-Z]/g,
-            timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
             ordinal = moment.ordinal,
             meridiem = moment.meridiem;
         // check if the character is a format
             timezoneHours = 0,
             timezoneMinutes = 0,
             isUsingUTC = false,
-            tokenCharacters = /(\\)?(MM?M?M?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?)/g,
-            inputCharacters = /(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,
-            timezoneParseRegex = /([\+\-]|\d\d)/gi,
             inputParts = string.match(inputCharacters),
             formatParts = format.match(tokenCharacters),
             monthRegex = moment.monthsParse,
     // date from string and array of format strings
     function makeDateFromStringAndArray(string, formats) {
         var output,
-            inputCharacters = /(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,
             inputParts = string.match(inputCharacters),
             scores = [],
             scoreToBeat = 99,