]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
test for utc-mode .weekday() being incorrect
authorAdam Shaw <arshaw@arshaw.com>
Tue, 17 Sep 2013 05:25:30 +0000 (22:25 -0700)
committerAdam Shaw <arshaw@arshaw.com>
Tue, 17 Sep 2013 05:41:33 +0000 (22:41 -0700)
test/moment/utc.js

index 89e94c0530d21749e5c0d5b4f6638df7ddcb6039..28153ae23bb9de620faa40c9e42c40ac6c101018 100644 (file)
@@ -86,6 +86,25 @@ exports.utc = {
         test.equal(moment.utc(m)._isUTC, true, "the explicit zone should stay in UTC");
         test.equal(moment.utc(m).zone(), 0, "the explicit zone should have an offset of 0");
 
+        test.done();
+    },
+
+    "weekday with utc" : function (test) {
+
+        var isLocalTimezoneOffset = !!new Date(Date.UTC(2013, 8, 15, 12, 0)).getTimezoneOffset();
+        if (isLocalTimezoneOffset) {
+            test.expect(1);
+            test.equal(
+                moment('2013-09-15T00:00:00Z').utc().weekday(), // first minute of the day
+                moment('2013-09-15T23:59:00Z').utc().weekday(), // last minute of the day
+                "a UTC-moment's .weekday() should not be affected by the local timezone"
+            );
+        } else {
+            // bug won't reveal itself if the local timezone offset is 0
+            test.expect(0);
+            process.stdout.write('(skipped weekday test)');
+        }
+
         test.done();
     }
 };