]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix broken year diff tests for Russia 1687/head
authorIskren Chernev <iskren.chernev@gmail.com>
Tue, 3 Jun 2014 06:22:09 +0000 (23:22 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Tue, 3 Jun 2014 06:22:09 +0000 (23:22 -0700)
Russia's zone offset is different on 1st of January (something we assumed
impossible in tests). Check to see if that is the case and skip the offending
test.

Fixes #1635 and #1612

test/moment/diff.js

index 649518e44f1c9bf96590fefe6c619b6beba049d7..a17632362595da36412203e6e96f777155105a1d 100644 (file)
@@ -174,9 +174,10 @@ exports.diff = {
     },
 
     "diff between utc and local" : function (test) {
-        test.expect(7);
-
-        test.equal(moment([2012]).utc().diff([2011], 'years'), 1, "year diff");
+        if (moment([2012]).zone() === moment([2011]).zone()) {
+            // Russia's zone offset on 1st of Jan 2012 vs 2011 is different
+            test.equal(moment([2012]).utc().diff([2011], 'years'), 1, "year diff");
+        }
         test.equal(moment([2010, 2, 2]).utc().diff([2010, 0, 2], 'months'), 2, "month diff");
         test.equal(moment([2010, 0, 4]).utc().diff([2010], 'days'), 3, "day diff");
         test.equal(moment([2010, 0, 22]).utc().diff([2010], 'weeks'), 3, "week diff");