]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Normalizing unit tests for -05:30 timezone
authorTim Wood <washwithcare@gmail.com>
Wed, 21 Mar 2012 18:14:11 +0000 (15:14 -0300)
committerTim Wood <washwithcare@gmail.com>
Wed, 21 Mar 2012 18:14:11 +0000 (15:14 -0300)
#217

test/moment/create.js
test/moment/utc.js

index ab02344c4c63e4d413fdfc2685675bf08fcb4a74..7e1f8bdbe7193ebc4ab5381076740f5b90078fb7 100644 (file)
@@ -167,7 +167,7 @@ exports.create = {
             }
             return '' + input;
         }
-        var hourOffset = Math.floor(offset / 60);
+        var hourOffset = (offset > 0) ? Math.floor(offset / 60) : Math.ceil(offset / 60);
         var minOffset = offset - (hourOffset * 60);
         var tz = (offset > 0) ? '-' + pad(hourOffset) + ':' + pad(minOffset) : '+' + pad(-hourOffset) + ':' + pad(-minOffset);
         var tz2 = tz.replace(':', '');
index b53e2cae2838d1dca802b6c70100f24182f3740d..1a0507e735be6dbf28e18d90c33f3be2fb3cf4f0 100644 (file)
@@ -20,7 +20,8 @@ exports.utc = {
             test.equal(m.date(), 2, "the date should be correct for local");
             test.equal(m.day(), 3, "the day should be correct for local");
         }
-        var expected = (24 + 3 - Math.floor(m.zone() / 60)) % 24;
+        var zone = (m.zone() > 0) ? Math.floor(m.zone() / 60) : Math.ceil(m.zone() / 60);
+        var expected = (24 + 3 - zone) % 24;
         test.equal(m.hours(), expected, "the hours (" + m.hours() + ") should be correct for local");
         test.equal(moment().utc().zone(), 0, "timezone in utc should always be zero");
         test.done();