From: Tim Wood Date: Wed, 11 Apr 2012 03:58:24 +0000 (-0700) Subject: Fixing merge conflicts with feature/parser branch X-Git-Tag: 1.6.0~1^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e24e543964638f6b27e9cd4e657af835a5aebb45;p=thirdparty%2Fmoment.git Fixing merge conflicts with feature/parser branch --- e24e543964638f6b27e9cd4e657af835a5aebb45 diff --cc moment.js index 5f742f07e,787c4074b..cccc991e1 --- a/moment.js +++ b/moment.js @@@ -7,20 -7,48 +7,49 @@@ (function (Date, undefined) { var moment, - round = Math.round, + VERSION = "1.5.0", + round = Math.round, i, + // internal storage for language config files languages = {}, + currentLanguage = 'en', + + // check for nodeJS hasModule = (typeof module !== 'undefined'), - paramsToParse = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'), - i, - jsonRegex = /^\/?Date\((\-?\d+)/i, - charactersToReplace = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|LT|LL?L?L?)/g, + + // parameters to check for on the lang config + langConfigProperties = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'), + + // ASP.NET json date format regex + aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, + + // format tokens + formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|LT|LL?L?L?)/g, + + // regexes for format z, zz + // TODO: When we drop support for z and zz, remove these variables nonuppercaseLetters = /[^A-Z]/g, timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g, - tokenCharacters = /(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g, - inputCharacters = /(\\)?([0-9]{1,2}[\u6708\uC6D4]|[0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi, + + // parsing tokens + parseMultipleFormatChunker = /([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi, + + // parsing token regexes + parseTokenOneDigit = /\d/, // 0 - 9 + parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 + parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 + parseTokenTwoDigits = /\d\d/, // 00 - 99 + parseTokenThreeDigits = /\d{3}/, // 000 - 999 + parseTokenFourDigits = /\d{4}/, // 0000 - 9999 + parseTokenWord = /[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i, // any word characters or numbers + parseTokenTimezone = /[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 + parseTokenT = /T/i, // T (ISO seperator) + + // preliminary iso regex + // 0000-00-00 + T + 00 or 00:00 or 00:00:00 + +00:00 or +0000 isoRegex = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d)?)?)?([\+\-]\d\d:?\d\d)?)?/, isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', + + // iso time formats and regexes isoTimes = [ ['HH:mm:ss', /T\d\d:\d\d:\d\d/], ['HH:mm', /T\d\d:\d\d/], @@@ -500,13 -581,8 +582,11 @@@ // language switching and caching moment.lang = function (key, values) { - var i, - param, - req, + var i, req, parse = []; + if (!key) { + return currentLanguage; + } if (values) { for (i = 0; i < 12; i++) { parse[i] = new RegExp('^' + values.months[i] + '|^' + values.monthsShort[i].replace('.', ''), 'i'); @@@ -515,11 -591,10 +595,11 @@@ languages[key] = values; } if (languages[key]) { - for (i = 0; i < paramsToParse.length; i++) { - param = paramsToParse[i]; - moment[param] = languages[key][param] || languages.en[param]; + for (i = 0; i < langConfigProperties.length; i++) { + moment[langConfigProperties[i]] = languages[key][langConfigProperties[i]] || + languages.en[langConfigProperties[i]]; } + currentLanguage = key; } else { if (hasModule) { req = require('./lang/' + key);