]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
ASP.net dates can be negative #161
authorTim Wood <washwithcare@gmail.com>
Mon, 20 Feb 2012 19:28:24 +0000 (11:28 -0800)
committerTim Wood <washwithcare@gmail.com>
Mon, 20 Feb 2012 20:40:57 +0000 (12:40 -0800)
moment.js
test/moment/create.js

index ce3e0d913fac87bb111b90b3c4e063b73714c99b..989295a69ffae58024a20b237516a04bafe106c8 100644 (file)
--- 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,
index 1da78f65f32524c724e39d6965ed314494e635ec..c8a0deb109ed2dba37ac518334bfe87b7bb07cec 100644 (file)
@@ -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)/");