]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
adding isDST teste 671/head
authorTim Wood <washwithcare@gmail.com>
Sat, 11 May 2013 17:39:36 +0000 (19:39 +0200)
committerTim Wood <washwithcare@gmail.com>
Sat, 11 May 2013 17:39:36 +0000 (19:39 +0200)
moment.js
test/moment/zones.js

index 954091b48f1f109182ff6c81c64c0561aba50958..267aba5ae6c66bf549b40f9ae2e71317260c3676 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         isDST : function () {
-            return (this.zone() < moment([this.year()]).zone() ||
-                this.zone() < moment([this.year(), 5]).zone());
+            return (this.zone() < this.clone().month(0).zone() ||
+                this.zone() < this.clone().month(5).zone());
         },
 
         day : function (input) {
                     }
                 }
                 this._d['set' + utc + 'Month'](input);
+                moment.updateOffset(this);
                 return this;
             } else {
                 return this._d['get' + utc + 'Month']();
index abf69126f93eb01d86095ea44363069118c993e2..8adecbf58814cf0bc37183a0bc2aa8060534202b 100644 (file)
@@ -366,6 +366,38 @@ exports.zones = {
 
         moment.updateOffset = oldOffset;
 
+        test.done();
+    },
+
+    "isDST" : function (test) {
+        var oldOffset = moment.updateOffset;
+
+        moment.updateOffset = function (mom) {
+            if (mom.month() > 2 && mom.month() < 9) {
+                mom.zone(-60);
+            } else {
+                mom.zone(0);
+            }
+        };
+
+        test.ok(!moment().month(0).isDST(),  "Jan should not be summer dst");
+        test.ok(moment().month(6).isDST(),   "Jul should be summer dst");
+        test.ok(!moment().month(11).isDST(), "Dec should not be summer dst");
+
+        moment.updateOffset = function (mom) {
+            if (mom.month() > 2 && mom.month() < 9) {
+                mom.zone(0);
+            } else {
+                mom.zone(-60);
+            }
+        };
+
+        test.ok(moment().month(0).isDST(),  "Jan should be winter dst");
+        test.ok(!moment().month(6).isDST(), "Jul should not be winter dst");
+        test.ok(moment().month(11).isDST(), "Dec should be winter dst");
+
+        moment.updateOffset = oldOffset;
+
         test.done();
     }