From: Tim Wood Date: Fri, 8 Mar 2013 03:51:31 +0000 (-0800) Subject: adding tests for unix timestamp and unix millisecond offset X-Git-Tag: 2.1.0~32^2~2^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52ef3e0179a4b2cc01b0fc38f150da65b593be93;p=thirdparty%2Fmoment.git adding tests for unix timestamp and unix millisecond offset --- diff --git a/moment.js b/moment.js index 3e7bee165..c19afbc54 100644 --- a/moment.js +++ b/moment.js @@ -1055,7 +1055,7 @@ }, unix : function () { - return Math.floor(+this._d / 1000); + return Math.floor(+this / 1000); }, toString : function () { diff --git a/test/moment/zones.js b/test/moment/zones.js index 0644949d1..0689da90d 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -177,6 +177,23 @@ exports.zones = { test.equal(zoneA.diff(other, 'hour', true), zoneC.diff(other, 'hour', true), "moment#diff should be the same in all zones"); test.equal(zoneA.diff(other, 'hour', true), zoneD.diff(other, 'hour', true), "moment#diff should be the same in all zones"); + test.done(); + }, + + "unix offset and timestamp" : function (test) { + var zoneA = moment(), + zoneB = moment(zoneA).zone(720), + zoneC = moment(zoneA).zone(360), + zoneD = moment(zoneA).zone(-690); + + test.equal(zoneA.unix(), zoneB.unix(), "moment#unix should be the same in all zones"); + test.equal(zoneA.unix(), zoneC.unix(), "moment#unix should be the same in all zones"); + test.equal(zoneA.unix(), zoneD.unix(), "moment#unix should be the same in all zones"); + + test.equal(+zoneA, +zoneB, "moment#valueOf should be the same in all zones"); + test.equal(+zoneA, +zoneC, "moment#valueOf should be the same in all zones"); + test.equal(+zoneA, +zoneD, "moment#valueOf should be the same in all zones"); + test.done(); }