From: Tim Wood Date: Mon, 20 Feb 2012 19:28:24 +0000 (-0800) Subject: ASP.net dates can be negative #161 X-Git-Tag: 1.5.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dc51da26d3a4bbc2de908c08bb3f3cf4b5cc210;p=thirdparty%2Fmoment.git ASP.net dates can be negative #161 --- diff --git a/moment.js b/moment.js index ce3e0d913..989295a69 100644 --- a/moment.js +++ b/moment.js @@ -12,7 +12,7 @@ hasModule = (typeof module !== 'undefined'), paramsToParse = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'), i, - jsonRegex = /^\/?Date\((\d+)/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?|zz?|ZZ?|LT|LL?L?L?)/g, nonuppercaseLetters = /[^A-Z]/g, timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g, diff --git a/test/moment/create.js b/test/moment/create.js index 1da78f65f..c8a0deb10 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -48,8 +48,9 @@ exports.create = { }, "string without format - json" : function(test) { - test.expect(4); + test.expect(5); test.equal(moment("Date(1325132654000)").valueOf(), 1325132654000, "Date(1325132654000)"); + test.equal(moment("Date(-1325132654000)").valueOf(), -1325132654000, "Date(-1325132654000)"); test.equal(moment("/Date(1325132654000)/").valueOf(), 1325132654000, "/Date(1325132654000)/"); test.equal(moment("/Date(1325132654000+0700)/").valueOf(), 1325132654000, "/Date(1325132654000+0700)/"); test.equal(moment("/Date(1325132654000-0700)/").valueOf(), 1325132654000, "/Date(1325132654000-0700)/");