From: Tim Wood Date: Wed, 7 Nov 2012 21:09:00 +0000 (-0800) Subject: Passing tests for iso week formats X-Git-Tag: 2.0.0~35^2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=586a48bc2e195eeaf265021383e6268195be4e9d;p=thirdparty%2Fmoment.git Passing tests for iso week formats --- diff --git a/moment.js b/moment.js index a6b5d47c6..1eaa8a42a 100644 --- a/moment.js +++ b/moment.js @@ -23,7 +23,7 @@ aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, // format tokens - formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYYY|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g, + formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g, localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g, // parsing tokens @@ -71,8 +71,8 @@ formatFunctions = {}, // tokens to ordinalize and pad - ordinalizeTokens = 'DDD w M D d'.split(' '), - paddedTokens = 'M D H h m s w'.split(' '), + ordinalizeTokens = 'DDD w W M D d'.split(' '), + paddedTokens = 'M D H h m s w W'.split(' '), formatTokenFunctions = { M : function () { @@ -110,6 +110,9 @@ a.setDate(a.getDate() + 4 - (a.getDay() || 7)); return Math.ceil((1 + (a - (new Date(a.getFullYear(), 0, 1))) / 864e5) / 7); }, + W : function () { + return this.isoWeek(); + }, YY : function () { return leftZeroFill(this.year() % 100, 2); },