From: Iskren Chernev Date: Thu, 14 Feb 2013 05:31:35 +0000 (-0800) Subject: Fixed a bug in cloning a Date X-Git-Tag: 2.1.0~64^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3ab886f7477413dcb5a6541cc7ee83b58522148;p=thirdparty%2Fmoment.git Fixed a bug in cloning a Date To clone a Date object d you need to convert it to a Number first and then pass it to Date constructor, like new Date(+d). Otherwise some browsers (firefox) cut milliseconds. --- diff --git a/test/moment/diff.js b/test/moment/diff.js index 53049d46d..1169e1881 100644 --- a/test/moment/diff.js +++ b/test/moment/diff.js @@ -13,7 +13,7 @@ exports.diff = { test.equal(moment(0).diff(1000), -1000, "0 - 1 second = -1000"); test.equal(moment(new Date(1000)).diff(1000), 0, "1 second - 1 second = 0"); var oneHourDate = new Date(), - nowDate = new Date(oneHourDate); + nowDate = new Date(+oneHourDate); oneHourDate.setHours(oneHourDate.getHours() + 1); test.equal(moment(oneHourDate).diff(nowDate), 60 * 60 * 1000, "1 hour from now = 360000"); test.done();