]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
adding tests for unix timestamp and unix millisecond offset
authorTim Wood <washwithcare@gmail.com>
Fri, 8 Mar 2013 03:51:31 +0000 (19:51 -0800)
committerTim Wood <washwithcare@gmail.com>
Fri, 8 Mar 2013 03:51:31 +0000 (19:51 -0800)
moment.js
test/moment/zones.js

index 3e7bee16520b669ce3f757ad9c60bc4cd1768ee7..c19afbc54b66632c0a46ace9d31c53322f2679b2 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         unix : function () {
-            return Math.floor(+this._d / 1000);
+            return Math.floor(+this / 1000);
         },
 
         toString : function () {
index 0644949d15472c2d03525e9576a819e8e0418bc4..0689da90def8dc4d6b5fc886c73e4f4d4ffeb416 100644 (file)
@@ -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();
     }