]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
JsHint all moment tests
authorIskren Chernev <iskren.chernev@gmail.com>
Sun, 14 Jul 2013 08:56:28 +0000 (01:56 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 14 Jul 2013 08:56:28 +0000 (01:56 -0700)
22 files changed:
Gruntfile.js
test/moment/add_subtract.js
test/moment/create.js
test/moment/days_in_month.js
test/moment/diff.js
test/moment/duration.js
test/moment/format.js
test/moment/getters_setters.js
test/moment/is_after.js
test/moment/is_before.js
test/moment/is_moment.js
test/moment/is_same.js
test/moment/is_valid.js
test/moment/leapyear.js
test/moment/mutable.js
test/moment/preparse_postformat.js
test/moment/sod_eod.js
test/moment/string_prototype.js
test/moment/utc.js
test/moment/week_year.js
test/moment/weekday.js
test/moment/weeks.js

index bffdeae1e53277d455e8ab0c2c3f372631cf4a4e..dbdc29d84c4d5da49ba63fe6ac715b0c94fd3a56 100644 (file)
@@ -65,6 +65,7 @@ module.exports = function (grunt) {
         },
         jshint: {
             all: ["Gruntfile.js", "moment.js", "lang/**/*.js"],
+            test: ["test/moment/*.js"],
             options: {
                 "node"     : true,
                 "browser"  : true,
index 0128b6a915aac5b692948b49c045fefbe9268b32..2d651b0db3e8dab7d32b84374e1c3eed7592dea9 100644 (file)
@@ -1,10 +1,10 @@
 var moment = require("../../moment");
 
 exports.add = {
-    "add short" : function(test) {
+    "add short" : function (test) {
         test.expect(12);
 
-        var a = moment();
+        var a = moment(), b, c;
         a.year(2011);
         a.month(9);
         a.date(12);
@@ -13,17 +13,17 @@ exports.add = {
         a.seconds(8);
         a.milliseconds(500);
 
-        test.equal(a.add({ms:50}).milliseconds(), 550, 'Add milliseconds');
-        test.equal(a.add({s:1}).seconds(), 9, 'Add seconds');
-        test.equal(a.add({m:1}).minutes(), 8, 'Add minutes');
-        test.equal(a.add({h:1}).hours(), 7, 'Add hours');
-        test.equal(a.add({d:1}).date(), 13, 'Add date');
-        test.equal(a.add({w:1}).date(), 20, 'Add week');
-        test.equal(a.add({M:1}).month(), 10, 'Add month');
-        test.equal(a.add({y:1}).year(), 2012, 'Add year');
+        test.equal(a.add({ms: 50}).milliseconds(), 550, 'Add milliseconds');
+        test.equal(a.add({s: 1}).seconds(), 9, 'Add seconds');
+        test.equal(a.add({m: 1}).minutes(), 8, 'Add minutes');
+        test.equal(a.add({h: 1}).hours(), 7, 'Add hours');
+        test.equal(a.add({d: 1}).date(), 13, 'Add date');
+        test.equal(a.add({w: 1}).date(), 20, 'Add week');
+        test.equal(a.add({M: 1}).month(), 10, 'Add month');
+        test.equal(a.add({y: 1}).year(), 2012, 'Add year');
 
-        var b = moment([2010, 0, 31]).add({M:1});
-        var c = moment([2010, 1, 28]).subtract({M:1});
+        b = moment([2010, 0, 31]).add({M: 1});
+        c = moment([2010, 1, 28]).subtract({M: 1});
 
         test.equal(b.month(), 1, 'add month, jan 31st to feb 28th');
         test.equal(b.date(), 28, 'add month, jan 31st to feb 28th');
@@ -32,7 +32,7 @@ exports.add = {
         test.done();
     },
 
-    "add long" : function(test) {
+    "add long" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -44,18 +44,18 @@ exports.add = {
         a.seconds(8);
         a.milliseconds(500);
 
-        test.equal(a.add({milliseconds:50}).milliseconds(), 550, 'Add milliseconds');
-        test.equal(a.add({seconds:1}).seconds(), 9, 'Add seconds');
-        test.equal(a.add({minutes:1}).minutes(), 8, 'Add minutes');
-        test.equal(a.add({hours:1}).hours(), 7, 'Add hours');
-        test.equal(a.add({days:1}).date(), 13, 'Add date');
-        test.equal(a.add({weeks:1}).date(), 20, 'Add week');
-        test.equal(a.add({months:1}).month(), 10, 'Add month');
-        test.equal(a.add({years:1}).year(), 2012, 'Add year');
+        test.equal(a.add({milliseconds: 50}).milliseconds(), 550, 'Add milliseconds');
+        test.equal(a.add({seconds: 1}).seconds(), 9, 'Add seconds');
+        test.equal(a.add({minutes: 1}).minutes(), 8, 'Add minutes');
+        test.equal(a.add({hours: 1}).hours(), 7, 'Add hours');
+        test.equal(a.add({days: 1}).date(), 13, 'Add date');
+        test.equal(a.add({weeks: 1}).date(), 20, 'Add week');
+        test.equal(a.add({months: 1}).month(), 10, 'Add month');
+        test.equal(a.add({years: 1}).year(), 2012, 'Add year');
         test.done();
     },
 
-    "add long singular" : function(test) {
+    "add long singular" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -67,21 +67,21 @@ exports.add = {
         a.seconds(8);
         a.milliseconds(500);
 
-        test.equal(a.add({millisecond:50}).milliseconds(), 550, 'Add milliseconds');
-        test.equal(a.add({second:1}).seconds(), 9, 'Add seconds');
-        test.equal(a.add({minute:1}).minutes(), 8, 'Add minutes');
-        test.equal(a.add({hour:1}).hours(), 7, 'Add hours');
-        test.equal(a.add({day:1}).date(), 13, 'Add date');
-        test.equal(a.add({week:1}).date(), 20, 'Add week');
-        test.equal(a.add({month:1}).month(), 10, 'Add month');
-        test.equal(a.add({year:1}).year(), 2012, 'Add year');
+        test.equal(a.add({millisecond: 50}).milliseconds(), 550, 'Add milliseconds');
+        test.equal(a.add({second: 1}).seconds(), 9, 'Add seconds');
+        test.equal(a.add({minute: 1}).minutes(), 8, 'Add minutes');
+        test.equal(a.add({hour: 1}).hours(), 7, 'Add hours');
+        test.equal(a.add({day: 1}).date(), 13, 'Add date');
+        test.equal(a.add({week: 1}).date(), 20, 'Add week');
+        test.equal(a.add({month: 1}).month(), 10, 'Add month');
+        test.equal(a.add({year: 1}).year(), 2012, 'Add year');
         test.done();
     },
 
-    "add string long" : function(test) {
+    "add string long" : function (test) {
         test.expect(9);
 
-        var a = moment();
+        var a = moment(), b;
         a.year(2011);
         a.month(9);
         a.date(12);
@@ -90,7 +90,7 @@ exports.add = {
         a.seconds(8);
         a.milliseconds(500);
 
-        var b = a.clone();
+        b = a.clone();
 
         test.equal(a.add('millisecond', 50).milliseconds(), 550, 'Add milliseconds');
         test.equal(a.add('second', 1).seconds(), 9, 'Add seconds');
@@ -104,10 +104,10 @@ exports.add = {
         test.done();
     },
 
-    "add string long singular" : function(test) {
+    "add string long singular" : function (test) {
         test.expect(9);
 
-        var a = moment();
+        var a = moment(), b;
         a.year(2011);
         a.month(9);
         a.date(12);
@@ -116,7 +116,7 @@ exports.add = {
         a.seconds(8);
         a.milliseconds(500);
 
-        var b = a.clone();
+        b = a.clone();
 
         test.equal(a.add('milliseconds', 50).milliseconds(), 550, 'Add milliseconds');
         test.equal(a.add('seconds', 1).seconds(), 9, 'Add seconds');
@@ -130,7 +130,7 @@ exports.add = {
         test.done();
     },
 
-    "add string short" : function(test) {
+    "add string short" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -153,7 +153,7 @@ exports.add = {
         test.done();
     },
 
-    "add string long reverse args" : function(test) {
+    "add string long reverse args" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -176,7 +176,7 @@ exports.add = {
         test.done();
     },
 
-    "add string long singular reverse args" : function(test) {
+    "add string long singular reverse args" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -199,7 +199,7 @@ exports.add = {
         test.done();
     },
 
-    "add string short reverse args" : function(test) {
+    "add string short reverse args" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -222,13 +222,13 @@ exports.add = {
         test.done();
     },
 
-    "add across DST" : function(test) {
+    "add across DST" : function (test) {
         test.expect(3);
 
-        var a = moment(new Date(2011, 2, 12, 5, 0, 0));
-        var b = moment(new Date(2011, 2, 12, 5, 0, 0));
-        var c = moment(new Date(2011, 2, 12, 5, 0, 0));
-        var d = moment(new Date(2011, 2, 12, 5, 0, 0));
+        var a = moment(new Date(2011, 2, 12, 5, 0, 0)),
+            b = moment(new Date(2011, 2, 12, 5, 0, 0)),
+            c = moment(new Date(2011, 2, 12, 5, 0, 0)),
+            d = moment(new Date(2011, 2, 12, 5, 0, 0));
         a.add('days', 1);
         b.add('hours', 24);
         c.add('months', 1);
index 2290fb41df456e77729e91bde06de9c066634c0b..f5dda63193dc1a2fe38e1b15a7925bac9f1595cb 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.create = {
-    "array" : function(test) {
+    "array" : function (test) {
         test.expect(8);
         test.ok(moment([2010]).toDate() instanceof Date, "[2010]");
         test.ok(moment([2010, 1]).toDate() instanceof Date, "[2010, 1]");
@@ -14,7 +14,7 @@ exports.create = {
         test.done();
     },
 
-    "array copying": function(test) {
+    "array copying": function (test) {
         var importantArray = [2009, 11];
         test.expect(1);
         moment(importantArray);
@@ -22,7 +22,7 @@ exports.create = {
         test.done();
     },
 
-    "multi format array copying": function(test) {
+    "multi format array copying": function (test) {
         var importantArray = ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'];
         test.expect(1);
         moment('1999-02-13', importantArray);
@@ -30,7 +30,7 @@ exports.create = {
         test.done();
     },
 
-    "number" : function(test) {
+    "number" : function (test) {
         test.expect(3);
         test.ok(moment(1000).toDate() instanceof Date, "1000");
         test.ok((moment(1000).valueOf() === 1000), "testing valueOf");
@@ -38,7 +38,7 @@ exports.create = {
         test.done();
     },
 
-    "unix" : function(test) {
+    "unix" : function (test) {
         test.expect(8);
         test.equal(moment.unix(1).valueOf(), 1000, "1 unix timestamp == 1000 Date.valueOf");
         test.equal(moment(1000).unix(), 1, "1000 Date.valueOf == 1 unix timestamp");
@@ -51,47 +51,47 @@ exports.create = {
         test.done();
     },
 
-    "date" : function(test) {
+    "date" : function (test) {
         test.expect(1);
         test.ok(moment(new Date()).toDate() instanceof Date, "new Date()");
         test.done();
     },
 
-    "date mutation" : function(test) {
+    "date mutation" : function (test) {
         test.expect(1);
         var a = new Date();
         test.ok(moment(a).toDate() !== a, "the date moment uses should not be the date passed in");
         test.done();
     },
 
-    "moment" : function(test) {
+    "moment" : function (test) {
         test.expect(2);
         test.ok(moment(moment()).toDate() instanceof Date, "moment(moment())");
         test.ok(moment(moment(moment())).toDate() instanceof Date, "moment(moment(moment()))");
         test.done();
     },
 
-    "cloning moment should only copy own properties" : function(test) {
+    "cloning moment should only copy own properties" : function (test) {
         test.expect(2);
         test.ok(!moment().clone().hasOwnProperty('month'), "Should not clone prototype methods");
         test.ok(!moment().clone().hasOwnProperty('_lang'), "Should not clone prototype objects");
         test.done();
     },
 
-    "undefined" : function(test) {
+    "undefined" : function (test) {
         test.expect(1);
         test.ok(moment().toDate() instanceof Date, "undefined");
         test.done();
     },
 
-    "string without format" : function(test) {
+    "string without format" : function (test) {
         test.expect(2);
         test.ok(moment("Aug 9, 1995").toDate() instanceof Date, "Aug 9, 1995");
         test.ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").toDate() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
         test.done();
     },
 
-    "string without format - json" : function(test) {
+    "string without format - json" : function (test) {
         test.expect(5);
         test.equal(moment("Date(1325132654000)").valueOf(), 1325132654000, "Date(1325132654000)");
         test.equal(moment("Date(-1325132654000)").valueOf(), -1325132654000, "Date(-1325132654000)");
@@ -101,7 +101,7 @@ exports.create = {
         test.done();
     },
 
-    "string with format dropped am/pm bug" : function(test) {
+    "string with format dropped am/pm bug" : function (test) {
         moment.lang('en');
         test.expect(3);
 
@@ -112,7 +112,7 @@ exports.create = {
         test.done();
     },
 
-    "empty string with formats" : function(test) {
+    "empty string with formats" : function (test) {
         test.expect(3);
 
         test.equal(moment(' ', 'MM').format('YYYY-MM-DD HH:mm:ss'), '0000-01-01 00:00:00', 'should not break if input is an empty string');
@@ -122,7 +122,7 @@ exports.create = {
         test.done();
     },
 
-    "matching am/pm" : function(test) {
+    "matching am/pm" : function (test) {
         test.expect(13);
 
         test.equal(moment('2012-09-03T03:00PM',   'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for PM');
@@ -144,7 +144,7 @@ exports.create = {
         test.done();
     },
 
-    "string with format" : function(test) {
+    "string with format" : function (test) {
         moment.lang('en');
         var a = [
                 ['MM-DD-YYYY',          '12-02-1999'],
@@ -186,12 +186,12 @@ exports.create = {
         test.done();
     },
 
-    "unix timestamp format" : function(test) {
-        var formats = ['X', 'X.S', 'X.SS', 'X.SSS'];
+    "unix timestamp format" : function (test) {
+        var formats = ['X', 'X.S', 'X.SS', 'X.SSS'], i, format;
 
         test.expect(formats.length * 4);
-        for (var i = 0; i < formats.length; i++) {
-            var format = formats[i];
+        for (i = 0; i < formats.length; i++) {
+            format = formats[i];
             test.equal(moment('1234567890',     format).valueOf(), 1234567890 * 1000,       format + " matches timestamp without milliseconds");
             test.equal(moment('1234567890.1',   format).valueOf(), 1234567890 * 1000 + 100, format + " matches timestamp with deciseconds");
             test.equal(moment('1234567890.12',  format).valueOf(), 1234567890 * 1000 + 120, format + " matches timestamp with centiseconds");
@@ -201,14 +201,14 @@ exports.create = {
         test.done();
     },
 
-    "string with format no separators" : function(test) {
+    "string with format no separators" : function (test) {
         moment.lang('en');
         var a = [
                 ['MMDDYYYY',          '12021999'],
                 ['DDMMYYYY',          '12021999'],
                 ['YYYYMMDD',          '19991202'],
                 ['DDMMMYYYY',         '10Sep2001']
-            ],i;
+            ], i;
 
         test.expect(a.length);
 
@@ -219,12 +219,12 @@ exports.create = {
         test.done();
     },
 
-    "string with format (timezone)" : function(test) {
+    "string with format (timezone)" : function (test) {
         test.expect(8);
         test.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"');
         test.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"');
         test.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"');
-        test.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"');
+        test.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 -07:0" ---> "H Z"');
         test.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"');
         test.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"');
         test.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"');
@@ -232,22 +232,23 @@ exports.create = {
         test.done();
     },
 
-    "string with format (timezone offset)" : function(test) {
+    "string with format (timezone offset)" : function (test) {
+        var a, b, c, d, e, f;
         test.expect(4);
-        var a = new Date(Date.UTC(2011, 0, 1, 1));
-        var b = moment('2011 1 1 0 -01:00', 'YYYY MM DD HH Z');
+        a = new Date(Date.UTC(2011, 0, 1, 1));
+        b = moment('2011 1 1 0 -01:00', 'YYYY MM DD HH Z');
         test.equal(a.getHours(), b.hours(), 'date created with utc == parsed string with timezone offset');
         test.equal(+a, +b, 'date created with utc == parsed string with timezone offset');
-        var c = moment('2011 2 1 10 -05:00', 'YYYY MM DD HH Z');
-        var d = moment('2011 2 1 8 -07:00', 'YYYY MM DD HH Z');
+        c = moment('2011 2 1 10 -05:00', 'YYYY MM DD HH Z');
+        d = moment('2011 2 1 8 -07:00', 'YYYY MM DD HH Z');
         test.equal(c.hours(), d.hours(), '10 am central time == 8 am pacific time');
-        var e = moment.utc('Fri, 20 Jul 2012 17:15:00', 'ddd, DD MMM YYYY HH:mm:ss');
-        var f = moment.utc('Fri, 20 Jul 2012 10:15:00 -0700', 'ddd, DD MMM YYYY HH:mm:ss ZZ');
+        e = moment.utc('Fri, 20 Jul 2012 17:15:00', 'ddd, DD MMM YYYY HH:mm:ss');
+        f = moment.utc('Fri, 20 Jul 2012 10:15:00 -0700', 'ddd, DD MMM YYYY HH:mm:ss ZZ');
         test.equal(e.hours(), f.hours(), 'parse timezone offset in utc');
         test.done();
     },
 
-    "string with array of formats" : function(test) {
+    "string with array of formats" : function (test) {
         test.expect(14);
 
         test.equal(moment('11-02-1999', ['MM-DD-YYYY', 'DD-MM-YYYY']).format('MM DD YYYY'), '11 02 1999', 'switching month and day');
@@ -272,7 +273,7 @@ exports.create = {
         test.done();
     },
 
-    "string with format - years" : function(test) {
+    "string with format - years" : function (test) {
         test.expect(4);
         test.equal(moment('67', 'YY').format('YYYY'), '2067', '67 > 2067');
         test.equal(moment('68', 'YY').format('YYYY'), '2068', '68 > 2068');
@@ -281,27 +282,27 @@ exports.create = {
         test.done();
     },
 
-    "implicit cloning" : function(test) {
+    "implicit cloning" : function (test) {
         test.expect(2);
-        var momentA = moment([2011, 10, 10]);
-        var momentB = moment(momentA);
+        var momentA = moment([2011, 10, 10]),
+            momentB = moment(momentA);
         momentA.month(5);
         test.equal(momentB.month(), 10, "Calling moment() on a moment will create a clone");
         test.equal(momentA.month(), 5, "Calling moment() on a moment will create a clone");
         test.done();
     },
 
-    "explicit cloning" : function(test) {
+    "explicit cloning" : function (test) {
         test.expect(2);
-        var momentA = moment([2011, 10, 10]);
-        var momentB = momentA.clone();
+        var momentA = moment([2011, 10, 10]),
+            momentB = momentA.clone();
         momentA.month(5);
         test.equal(momentB.month(), 10, "Calling moment() on a moment will create a clone");
         test.equal(momentA.month(), 5, "Calling moment() on a moment will create a clone");
         test.done();
     },
 
-    "cloning carrying over utc mode" : function(test) {
+    "cloning carrying over utc mode" : function (test) {
         test.expect(8);
 
         test.equal(moment().local().clone()._isUTC, false, "An explicit cloned local moment should have _isUTC == false");
@@ -316,49 +317,49 @@ exports.create = {
         test.done();
     },
 
-    "parsing iso" : function(test) {
-        var offset = moment([2011, 9, 08]).zone();
-        var pad = function(input) {
-            if (input < 10) {
-                return '0' + input;
-            }
-            return '' + input;
-        }
-        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(':', '');
-        var formats = [
-            ['2011-10-08',                    '2011-10-08T00:00:00.000' + tz],
-            ['2011-10-08T18',                 '2011-10-08T18:00:00.000' + tz],
-            ['2011-10-08T18:04',              '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08T18:04:20',           '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08T18:04' + tz,         '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08T18:04:20' + tz,      '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08T18:04' + tz2,        '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08T18:04:20' + tz2,     '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08T18:04:20.1' + tz2,   '2011-10-08T18:04:20.100' + tz],
-            ['2011-10-08T18:04:20.11' + tz2,  '2011-10-08T18:04:20.110' + tz],
-            ['2011-10-08T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
-            ['2011-10-08 18',                 '2011-10-08T18:00:00.000' + tz],
-            ['2011-10-08 18:04',              '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08 18:04:20',           '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08 18:04' + tz,         '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08 18:04:20' + tz,      '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08 18:04' + tz2,        '2011-10-08T18:04:00.000' + tz],
-            ['2011-10-08 18:04:20' + tz2,     '2011-10-08T18:04:20.000' + tz],
-            ['2011-10-08 18:04:20.1' + tz2,   '2011-10-08T18:04:20.100' + tz],
-            ['2011-10-08 18:04:20.11' + tz2,  '2011-10-08T18:04:20.110' + tz],
-            ['2011-10-08 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz]
-        ];
+    "parsing iso" : function (test) {
+        var offset = moment([2011, 9, 08]).zone(),
+            pad = function (input) {
+                if (input < 10) {
+                    return '0' + input;
+                }
+                return '' + input;
+            },
+            hourOffset = (offset > 0) ? Math.floor(offset / 60) : Math.ceil(offset / 60),
+            minOffset = offset - (hourOffset * 60),
+            tz = (offset > 0) ? '-' + pad(hourOffset) + ':' + pad(minOffset) : '+' + pad(-hourOffset) + ':' + pad(-minOffset),
+            tz2 = tz.replace(':', ''),
+            formats = [
+                ['2011-10-08',                    '2011-10-08T00:00:00.000' + tz],
+                ['2011-10-08T18',                 '2011-10-08T18:00:00.000' + tz],
+                ['2011-10-08T18:04',              '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08T18:04:20',           '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08T18:04' + tz,         '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08T18:04:20' + tz,      '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08T18:04' + tz2,        '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08T18:04:20' + tz2,     '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08T18:04:20.1' + tz2,   '2011-10-08T18:04:20.100' + tz],
+                ['2011-10-08T18:04:20.11' + tz2,  '2011-10-08T18:04:20.110' + tz],
+                ['2011-10-08T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
+                ['2011-10-08 18',                 '2011-10-08T18:00:00.000' + tz],
+                ['2011-10-08 18:04',              '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08 18:04:20',           '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08 18:04' + tz,         '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08 18:04:20' + tz,      '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08 18:04' + tz2,        '2011-10-08T18:04:00.000' + tz],
+                ['2011-10-08 18:04:20' + tz2,     '2011-10-08T18:04:20.000' + tz],
+                ['2011-10-08 18:04:20.1' + tz2,   '2011-10-08T18:04:20.100' + tz],
+                ['2011-10-08 18:04:20.11' + tz2,  '2011-10-08T18:04:20.110' + tz],
+                ['2011-10-08 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz]
+            ], i;
         test.expect(formats.length);
-        for (var i = 0; i < formats.length; i++) {
+        for (i = 0; i < formats.length; i++) {
             test.equal(formats[i][1], moment(formats[i][0]).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), "moment should be able to parse ISO " + formats[i][0]);
         }
         test.done();
     },
 
-    "parsing iso with T" : function(test) {
+    "parsing iso with T" : function (test) {
         test.expect(9);
 
         test.equal(moment('2011-10-08T18')._f, "YYYY-MM-DDTHH", "should include 'T' in the format");
@@ -376,7 +377,7 @@ exports.create = {
         test.done();
     },
 
-    "parsing iso Z timezone" : function(test) {
+    "parsing iso Z timezone" : function (test) {
         var i,
             formats = [
             ['2011-10-08T18:04Z',             '2011-10-08T18:04:00.000+00:00'],
@@ -390,7 +391,7 @@ exports.create = {
         test.done();
     },
 
-    "parsing iso Z timezone into local" : function(test) {
+    "parsing iso Z timezone into local" : function (test) {
         test.expect(1);
 
         var m = moment('2011-10-08T18:04:20.111Z');
@@ -400,7 +401,7 @@ exports.create = {
         test.done();
     },
 
-    "null" : function(test) {
+    "null" : function (test) {
         test.expect(3);
         test.equal(moment(''), null, "Calling moment('')");
         test.equal(moment(null), null, "Calling moment(null)");
@@ -408,7 +409,7 @@ exports.create = {
         test.done();
     },
 
-    "first century" : function(test) {
+    "first century" : function (test) {
         test.expect(9);
         test.equal(moment([0, 0, 1]).format("YYYY-MM-DD"), "0000-01-01", "Year AD 0");
         test.equal(moment([99, 0, 1]).format("YYYY-MM-DD"), "0099-01-01", "Year AD 99");
@@ -422,7 +423,7 @@ exports.create = {
         test.done();
     },
 
-    "six digit years" : function(test) {
+    "six digit years" : function (test) {
         test.expect(8);
         test.equal(moment([-270000, 0, 1]).format("YYYYY-MM-DD"), "-270000-01-01", "format BC 270,001");
         test.equal(moment([ 270000, 0, 1]).format("YYYYY-MM-DD"), "270000-01-01", "format AD 270,000");
@@ -435,7 +436,7 @@ exports.create = {
         test.done();
     },
 
-    "negative four digit years" : function(test) {
+    "negative four digit years" : function (test) {
         test.expect(2);
         test.equal(moment("-1000-01-01", "YYYYY-MM-DD").toDate().getFullYear(), -1000, "parse BC 1,001");
         test.equal(moment.utc("-1000-01-01", "YYYYY-MM-DD").toDate().getUTCFullYear(), -1000, "parse utc BC 1,001");
index ffa2546731f0665b4c5d3655b33c9fbd7a7c97ad..2b786557893a8ac9d7f90e13609b7c15cd9aa75b 100644 (file)
@@ -1,23 +1,23 @@
 var moment = require("../../moment");
 
 exports.days_in_month = {
-    "days in month" : function(test) {
+    "days in month" : function (test) {
         test.expect(24);
-        var months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
-        for (var i = 0; i < 12; i++) {
+        var months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], i;
+        for (i = 0; i < 12; i++) {
             test.equal(moment([2012, i]).daysInMonth(),
                        months[i],
-                       moment([2012, i]).format('L') + " should have " + months[i] + " days. (beginning of month " + i + ')')
+                       moment([2012, i]).format('L') + " should have " + months[i] + " days. (beginning of month " + i + ')');
         }
-        for (var i = 0; i < 12; i++) {
+        for (i = 0; i < 12; i++) {
             test.equal(moment([2012, i, months[i]]).daysInMonth(),
                        months[i],
-                       moment([2012, i, months[i]]).format('L') + " should have " + months[i] + " days. (end of month " + i + ')')
+                       moment([2012, i, months[i]]).format('L') + " should have " + months[i] + " days. (end of month " + i + ')');
         }
         test.done();
     },
 
-    "days in month leap years" : function(test) {
+    "days in month leap years" : function (test) {
         test.expect(4);
         test.equal(moment([2010, 1]).daysInMonth(), 28, "Feb 2010 should have 28 days");
         test.equal(moment([2100, 1]).daysInMonth(), 28, "Feb 2100 should have 28 days");
index 997d812a04bdfd6200bfe8ebfd7d31c3065ec368..739e7fae44a7ec7292fa1b09f8be12a7c3689982 100644 (file)
@@ -33,7 +33,7 @@ function dstForYear(year) {
 }
 
 exports.diff = {
-    "diff" : function(test) {
+    "diff" : function (test) {
         test.expect(5);
 
         test.equal(moment(1000).diff(0), 1000, "1 second - 0 = 1000");
@@ -47,7 +47,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff key after" : function(test) {
+    "diff key after" : function (test) {
         test.expect(10);
 
         test.equal(moment([2010]).diff([2011], 'years'), -1, "year diff");
@@ -63,7 +63,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff key before" : function(test) {
+    "diff key before" : function (test) {
         test.expect(10);
 
         test.equal(moment([2011]).diff([2010], 'years'), 1, "year diff");
@@ -79,7 +79,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff key before singular" : function(test) {
+    "diff key before singular" : function (test) {
         test.expect(10);
 
         test.equal(moment([2011]).diff([2010], 'year'), 1, "year diff singular");
@@ -95,7 +95,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff key before abbreviated" : function(test) {
+    "diff key before abbreviated" : function (test) {
         test.expect(10);
 
         test.equal(moment([2011]).diff([2010], 'y'), 1, "year diff abbreviated");
@@ -111,14 +111,14 @@ exports.diff = {
         test.done();
     },
 
-    "diff month" : function(test) {
+    "diff month" : function (test) {
         test.expect(1);
 
         test.equal(moment([2011, 0, 31]).diff([2011, 2, 1], 'months'), -1, "month diff");
         test.done();
     },
 
-    "diff across DST" : function(test) {
+    "diff across DST" : function (test) {
         var dst = dstForYear(2012), a, b, daysInMonth;
         if (!dst) {
             console.log("No DST?");
@@ -157,7 +157,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff overflow" : function(test) {
+    "diff overflow" : function (test) {
         test.expect(4);
 
         test.equal(moment([2011]).diff([2010], 'months'), 12, "month diff");
@@ -167,7 +167,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff between utc and local" : function(test) {
+    "diff between utc and local" : function (test) {
         test.expect(7);
 
         test.equal(moment([2011]).utc().diff([2010], 'years'), 1, "year diff");
@@ -181,7 +181,7 @@ exports.diff = {
         test.done();
     },
 
-    "diff floored" : function(test) {
+    "diff floored" : function (test) {
         test.expect(7);
 
         test.equal(moment([2010, 0, 1, 23]).diff([2010], 'day'), 0, "23 hours = 0 days");
@@ -195,7 +195,7 @@ exports.diff = {
         test.done();
     },
 
-    "year diffs include dates" : function(test) {
+    "year diffs include dates" : function (test) {
         test.expect(1);
 
         test.ok(moment([2012, 1, 19]).diff(moment([2002, 1, 20]), 'years', true) < 10, "year diff should include date of month");
@@ -208,13 +208,13 @@ exports.diff = {
 
         // due to floating point math errors, these tests just need to be accurate within 0.00000001
         equal(test, moment([2012, 0, 1]).diff([2012, 1, 1], 'months', true), -1, 'Jan 1 to Feb 1 should be 1 month');
-        equal(test, moment([2012, 0, 1]).diff([2012, 0, 1, 12], 'months', true), -0.5/31, 'Jan 1 to Jan 1 noon should be 0.5/31 months');
+        equal(test, moment([2012, 0, 1]).diff([2012, 0, 1, 12], 'months', true), -0.5 / 31, 'Jan 1 to Jan 1 noon should be 0.5 / 31 months');
         equal(test, moment([2012, 0, 15]).diff([2012, 1, 15], 'months', true), -1, 'Jan 15 to Feb 15 should be 1 month');
         equal(test, moment([2012, 0, 28]).diff([2012, 1, 28], 'months', true), -1, 'Jan 28 to Feb 28 should be 1 month');
-        equal(test, moment([2012, 0, 31]).diff([2012, 1, 29], 'months', true), -1 + (2/30), 'Jan 31 to Feb 29 should be 1 - (2/30) months');
-        equal(test, moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), -2 + (30/31), 'Jan 31 to Mar 1 should be 2 - (30/31) months');
-        equal(test, moment([2012, 0, 31]).diff([2012, 2, 1, 12], 'months', true), -2 + (29.5/31), 'Jan 31 to Mar 1 should be 2 - (29.5/31) months');
-        equal(test, moment([2012, 0, 1]).diff([2012, 0, 31], 'months', true), -(30 / 31), 'Jan 1 to Jan 31 should be 30/31 months');
+        equal(test, moment([2012, 0, 31]).diff([2012, 1, 29], 'months', true), -1 + (2 / 30), 'Jan 31 to Feb 29 should be 1 - (2 / 30) months');
+        equal(test, moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), -2 + (30 / 31), 'Jan 31 to Mar 1 should be 2 - (30 / 31) months');
+        equal(test, moment([2012, 0, 31]).diff([2012, 2, 1, 12], 'months', true), -2 + (29.5 / 31), 'Jan 31 to Mar 1 should be 2 - (29.5 / 31) months');
+        equal(test, moment([2012, 0, 1]).diff([2012, 0, 31], 'months', true), -(30 / 31), 'Jan 1 to Jan 31 should be 30 / 31 months');
 
         test.done();
     },
@@ -230,9 +230,9 @@ exports.diff = {
         equal(test, moment([2012, 11, 31]).diff([2013, 11, 31], 'years', true), -1, 'Dec 31 2012 to Dec 31 2013 should be 1 year');
         equal(test, moment([2012, 0, 1]).diff([2013, 6, 1], 'years', true), -1.5, 'Jan 1 2012 to Jul 1 2013 should be 1.5 years');
         equal(test, moment([2012, 0, 31]).diff([2013, 6, 31], 'years', true), -1.5, 'Jan 31 2012 to Jul 31 2013 should be 1.5 years');
-        equal(test, moment([2012, 0, 1]).diff([2013, 0, 1, 12], 'years', true), -1-(0.5/31)/12, 'Jan 1 2012 to Jan 1 2013 noon should be 1+(0.5/31)/12 years');
-        equal(test, moment([2012, 0, 1]).diff([2013, 6, 1, 12], 'years', true), -1.5-(0.5/31)/12, 'Jan 1 2012 to Jul 1 2013 noon should be 1.5+(0.5/31)/12 years');
-        equal(test, moment([2012, 1, 29]).diff([2013, 1, 28], 'years', true), -1 + (1/28.5)/12, 'Feb 29 2012 to Feb 28 2013 should be 1-(1/28.5)/12 years');
+        equal(test, moment([2012, 0, 1]).diff([2013, 0, 1, 12], 'years', true), -1 - (0.5 / 31) / 12, 'Jan 1 2012 to Jan 1 2013 noon should be 1+(0.5 / 31) / 12 years');
+        equal(test, moment([2012, 0, 1]).diff([2013, 6, 1, 12], 'years', true), -1.5 - (0.5 / 31) / 12, 'Jan 1 2012 to Jul 1 2013 noon should be 1.5+(0.5 / 31) / 12 years');
+        equal(test, moment([2012, 1, 29]).diff([2013, 1, 28], 'years', true), -1 + (1 / 28.5) / 12, 'Feb 29 2012 to Feb 28 2013 should be 1-(1 / 28.5) / 12 years');
 
         test.done();
     }
index 8b4b0e4e8c2bb0d72bc7bf984c44e721c8e8ca3a..1aaee7d23d141f1db068c450c9396f41552315fa 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.duration = {
-    "object instantiation" : function(test) {
+    "object instantiation" : function (test) {
         var d = moment.duration({
             years: 2,
             months: 3,
@@ -25,13 +25,13 @@ exports.duration = {
         test.done();
     },
 
-    "milliseconds instantiation" : function(test) {
+    "milliseconds instantiation" : function (test) {
         test.expect(1);
         test.equal(moment.duration(72).milliseconds(), 72, "milliseconds");
         test.done();
     },
 
-    "instantiation by type" : function(test) {
+    "instantiation by type" : function (test) {
         test.expect(16);
         test.equal(moment.duration(1, "years").years(),         1, "years");
         test.equal(moment.duration(1, "y").years(),         1, "y");
@@ -52,7 +52,7 @@ exports.duration = {
         test.done();
     },
 
-    "shortcuts" : function(test) {
+    "shortcuts" : function (test) {
         test.expect(8);
         test.equal(moment.duration({y: 1}).years(),         1, "years = y");
         test.equal(moment.duration({M: 2}).months(),        2, "months = M");
@@ -65,7 +65,7 @@ exports.duration = {
         test.done();
     },
 
-    "generic getter" : function(test) {
+    "generic getter" : function (test) {
         test.expect(24);
         test.equal(moment.duration(1, "years").get("years"),                1, "years");
         test.equal(moment.duration(1, "years").get("year"),                 1, "years = year");
@@ -94,7 +94,7 @@ exports.duration = {
         test.done();
     },
 
-    "instantiation from another duration" : function(test) {
+    "instantiation from another duration" : function (test) {
         var simple = moment.duration(1234),
             lengthy = moment.duration(60 * 60 * 24 * 360 * 1e3),
             complicated = moment.duration({
@@ -115,7 +115,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan zero" : function(test) {
+    "instatiation from serialized C# TimeSpan zero" : function (test) {
         test.expect(6);
         test.equal(moment.duration("00:00:00").years(), 0, "0 years");
         test.equal(moment.duration("00:00:00").days(), 0, "0 days");
@@ -126,7 +126,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan with days" : function(test) {
+    "instatiation from serialized C# TimeSpan with days" : function (test) {
         test.expect(6);
         test.equal(moment.duration("1.02:03:04.9999999").years(), 0, "0 years");
         test.equal(moment.duration("1.02:03:04.9999999").days(), 1, "1 day");
@@ -137,7 +137,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan without days" : function(test) {
+    "instatiation from serialized C# TimeSpan without days" : function (test) {
         test.expect(6);
         test.equal(moment.duration("01:02:03.9999999").years(), 0, "0 years");
         test.equal(moment.duration("01:02:03.9999999").days(), 0, "0 days");
@@ -148,7 +148,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan without days or milliseconds" : function(test) {
+    "instatiation from serialized C# TimeSpan without days or milliseconds" : function (test) {
         test.expect(6);
         test.equal(moment.duration("01:02:03").years(), 0, "0 years");
         test.equal(moment.duration("01:02:03").days(), 0, "0 days");
@@ -159,7 +159,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan without milliseconds" : function(test) {
+    "instatiation from serialized C# TimeSpan without milliseconds" : function (test) {
         test.expect(6);
         test.equal(moment.duration("1.02:03:04").years(), 0, "0 years");
         test.equal(moment.duration("1.02:03:04").days(), 1, "1 day");
@@ -170,7 +170,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan maxValue" : function(test) {
+    "instatiation from serialized C# TimeSpan maxValue" : function (test) {
         test.expect(6);
         test.equal(moment.duration("10675199.02:48:05.4775807").years(), 29653, "29653 years");
         test.equal(moment.duration("10675199.02:48:05.4775807").days(), 29, "29 day");
@@ -181,7 +181,7 @@ exports.duration = {
         test.done();
     },
 
-    "instatiation from serialized C# TimeSpan minValue" : function(test) {
+    "instatiation from serialized C# TimeSpan minValue" : function (test) {
         test.expect(6);
         test.equal(moment.duration("-10675199.02:48:05.4775808").years(), -29653, "29653 years");
         test.equal(moment.duration("-10675199.02:48:05.4775808").days(), -29, "29 day");
@@ -192,7 +192,7 @@ exports.duration = {
         test.done();
     },
 
-    "humanize" : function(test) {
+    "humanize" : function (test) {
         test.expect(32);
         moment.lang('en');
         test.equal(moment.duration({seconds: 44}).humanize(),  "a few seconds", "44 seconds = a few seconds");
@@ -230,7 +230,7 @@ exports.duration = {
         test.done();
     },
 
-    "humanize duration with suffix" : function(test) {
+    "humanize duration with suffix" : function (test) {
         test.expect(2);
         moment.lang('en');
         test.equal(moment.duration({seconds:  44}).humanize(true),  "in a few seconds", "44 seconds = a few seconds");
@@ -238,7 +238,7 @@ exports.duration = {
         test.done();
     },
 
-    "bubble value up" : function(test) {
+    "bubble value up" : function (test) {
         test.expect(5);
         test.equal(moment.duration({milliseconds: 61001}).milliseconds(), 1, "61001 milliseconds has 1 millisecond left over");
         test.equal(moment.duration({milliseconds: 61001}).seconds(),      1, "61001 milliseconds has 1 second left over");
@@ -249,7 +249,7 @@ exports.duration = {
         test.done();
     },
 
-    "clipping" : function(test) {
+    "clipping" : function (test) {
         test.expect(18);
         test.equal(moment.duration({months: 11}).months(), 11, "11 months is 11 months");
         test.equal(moment.duration({months: 11}).years(),  0,  "11 months makes no year");
@@ -274,7 +274,7 @@ exports.duration = {
         test.done();
     },
 
-    "effective equivalency" : function(test) {
+    "effective equivalency" : function (test) {
         test.expect(7);
         test.deepEqual(moment.duration({seconds: 1})._data,  moment.duration({milliseconds: 1000})._data, "1 second is the same as 1000 milliseconds");
         test.deepEqual(moment.duration({seconds: 60})._data, moment.duration({minutes: 1})._data,         "1 minute is the same as 60 seconds");
@@ -286,7 +286,7 @@ exports.duration = {
         test.done();
     },
 
-    "asGetters" : function(test) {
+    "asGetters" : function (test) {
         var d = moment.duration({
             years: 2,
             months: 3,
@@ -310,7 +310,7 @@ exports.duration = {
         test.done();
     },
 
-    "generic as getter" : function(test) {
+    "generic as getter" : function (test) {
         var d = moment.duration({
             years: 2,
             months: 3,
@@ -350,7 +350,7 @@ exports.duration = {
         test.done();
     },
 
-    "isDuration" : function(test) {
+    "isDuration" : function (test) {
         test.expect(3);
         test.ok(moment.isDuration(moment.duration(12345678)), "correctly says true");
         test.ok(!moment.isDuration(moment()), "moment object is not a duration");
@@ -358,7 +358,7 @@ exports.duration = {
         test.done();
     },
 
-    "add" : function(test) {
+    "add" : function (test) {
         test.expect(4);
 
         var d = moment.duration({months: 4, weeks: 3, days: 2});
@@ -366,12 +366,12 @@ exports.duration = {
         test.equal(d.add(1, 'month')._months, 5, 'Add months');
         test.equal(d.add(5, 'days')._days, 28, 'Add days');
         test.equal(d.add(10000)._milliseconds, 10000, 'Add milliseconds');
-        test.equal(d.add({h: 23, m: 59})._milliseconds, 23*60*60*1000 + 59*60*1000 + 10000, 'Add hour:minute');
+        test.equal(d.add({h: 23, m: 59})._milliseconds, 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 10000, 'Add hour:minute');
 
         test.done();
     },
 
-    "add and bubble" : function(test) {
+    "add and bubble" : function (test) {
         test.expect(4);
 
         test.equal(moment.duration(1, 'second').add(1000, 'milliseconds').seconds(), 2, 'Adding milliseconds should bubble up to seconds');
@@ -382,7 +382,7 @@ exports.duration = {
         test.done();
     },
 
-    "subtract and bubble" : function(test) {
+    "subtract and bubble" : function (test) {
         test.expect(4);
 
         test.equal(moment.duration(2, 'second').subtract(1000, 'milliseconds').seconds(), 1, 'Subtracting milliseconds should bubble up to seconds');
@@ -393,15 +393,15 @@ exports.duration = {
         test.done();
     },
 
-    "subtract" : function(test) {
+    "subtract" : function (test) {
         test.expect(4);
 
         var d = moment.duration({months: 2, weeks: 2, days: 0, hours: 5});
         // for some reason, d._data._months does not get updated; use d._months instead.
         test.equal(d.subtract(1, 'months')._months, 1, 'Subtract months');
         test.equal(d.subtract(14, 'days')._days, 0, 'Subtract days');
-        test.equal(d.subtract(10000)._milliseconds, 5*60*60*1000 - 10000, 'Subtract milliseconds');
-        test.equal(d.subtract({h: 1, m: 59})._milliseconds, 3*60*60*1000 + 1*60*1000 - 10000, 'Subtract hour:minute');
+        test.equal(d.subtract(10000)._milliseconds, 5 * 60 * 60 * 1000 - 10000, 'Subtract milliseconds');
+        test.equal(d.subtract({h: 1, m: 59})._milliseconds, 3 * 60 * 60 * 1000 + 1 * 60 * 1000 - 10000, 'Subtract hour:minute');
 
         test.done();
     }
index 1534c064543b681c0d3aec8997980f1e842f6384..6408bb60e6e979a67233dab61f82d0b644717379 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.format = {
-    "format YY" : function(test) {
+    "format YY" : function (test) {
         test.expect(1);
 
         var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
@@ -9,7 +9,7 @@ exports.format = {
         test.done();
     },
 
-    "format escape brackets" : function(test) {
+    "format escape brackets" : function (test) {
         test.expect(9);
 
         moment.lang('en');
@@ -27,7 +27,7 @@ exports.format = {
         test.done();
     },
 
-    "format milliseconds" : function(test) {
+    "format milliseconds" : function (test) {
         test.expect(6);
         var b = moment(new Date(2009, 1, 14, 15, 25, 50, 123));
         test.equal(b.format('S'), '1', 'Deciseconds');
@@ -40,11 +40,11 @@ exports.format = {
         test.done();
     },
 
-    "format timezone" : function(test) {
+    "format timezone" : function (test) {
         test.expect(2);
 
-        var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
-        var explanation = 'moment().format("z") = ' + b.format('z') + ' It should be something like "PST"'
+        var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+            explanation = 'moment().format("z") = ' + b.format('z') + ' It should be something like "PST"';
         if (moment().zone() === -60) {
             explanation += "For UTC+1 this is a known issue, see https://github.com/timrwood/moment/issues/162";
         }
@@ -53,7 +53,7 @@ exports.format = {
         test.done();
     },
 
-    "format multiple with zone" : function(test) {
+    "format multiple with zone" : function (test) {
         test.expect(1);
 
         var b = moment('2012-10-08 -1200', ['YYYY-MM-DD HH:mm ZZ', 'YYYY-MM-DD ZZ', 'YYYY-MM-DD']);
@@ -61,7 +61,7 @@ exports.format = {
         test.done();
     },
 
-    "isDST" : function(test) {
+    "isDST" : function (test) {
         test.expect(2);
 
         var janOffset = new Date(2011, 0, 1).getTimezoneOffset(),
@@ -87,7 +87,7 @@ exports.format = {
         test.done();
     },
 
-    "unix timestamp" : function(test) {
+    "unix timestamp" : function (test) {
         test.expect(4);
 
         var m = moment('1234567890.123', 'X');
@@ -99,7 +99,7 @@ exports.format = {
         test.done();
     },
 
-    "zone" : function(test) {
+    "zone" : function (test) {
         test.expect(3);
 
         if (moment().zone() > 0) {
@@ -108,26 +108,26 @@ exports.format = {
         if (moment().zone() < 0) {
             test.ok(moment().format('ZZ').indexOf('+') > -1, 'When the zone() offset is less than 0, the ISO offset should be greater than zero');
         }
-        if (moment().zone() == 0) {
+        if (moment().zone() === 0) {
             test.ok(moment().format('ZZ').indexOf('+') > -1, 'When the zone() offset is equal to 0, the ISO offset should be positive zero');
         }
         if (moment().zone() === 0) {
-           test.equal(moment().zone(), 0, 'moment.fn.zone should be a multiple of 15 (was ' + moment().zone() + ')');
+            test.equal(moment().zone(), 0, 'moment.fn.zone should be a multiple of 15 (was ' + moment().zone() + ')');
         } else {
-           test.equal(moment().zone() % 15, 0, 'moment.fn.zone should be a multiple of 15 (was ' + moment().zone() + ')');
+            test.equal(moment().zone() % 15, 0, 'moment.fn.zone should be a multiple of 15 (was ' + moment().zone() + ')');
         }
         test.equal(moment().zone(), new Date().getTimezoneOffset(), 'zone should equal getTimezoneOffset');
         test.done();
     },
 
-    "default format" : function(test) {
+    "default format" : function (test) {
         test.expect(1);
         var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\d[\+\-]\d\d:\d\d/;
         test.ok(isoRegex.exec(moment().format()), "default format (" + moment().format() + ") should match ISO");
         test.done();
     },
 
-    "escaping quotes" : function(test) {
+    "escaping quotes" : function (test) {
         test.expect(4);
         moment.lang('en');
         var date = moment([2012, 0]);
@@ -138,7 +138,7 @@ exports.format = {
         test.done();
     },
 
-    "toJSON" : function(test) {
+    "toJSON" : function (test) {
         var supportsJson = typeof JSON !== "undefined" && JSON.stringify && JSON.stringify.call,
             date = moment("2012-10-09T21:30:40.678+0100");
 
@@ -155,14 +155,14 @@ exports.format = {
         test.done();
     },
 
-    "toISOString" : function(test) {
+    "toISOString" : function (test) {
         var date = moment.utc("2012-10-09T20:30:40.678");
 
         test.equal(date.toISOString(), "2012-10-09T20:30:40.678Z", "should output ISO8601 on moment.fn.toISOString");
         test.done();
     },
 
-    "weeks format" : function(test) {
+    "weeks format" : function (test) {
 
         // http://en.wikipedia.org/wiki/ISO_week_date
         var cases = {
@@ -181,18 +181,18 @@ exports.format = {
             "2010-01-01": "2009-53",
             "2010-01-02": "2009-53",
             "2010-01-03": "2009-53"
-        };
+        }, i, iso, the;
 
-        for (var i in cases) {
-            var iso = cases[i].split('-').pop();
-            var the = moment(i).format('WW');
+        for (i in cases) {
+            iso = cases[i].split('-').pop();
+            the = moment(i).format('WW');
             test.equal(iso, the, i + ": should be " + iso + ", but " + the);
         }
 
         test.done();
     },
 
-    "iso week year formats" : function(test) {
+    "iso week year formats" : function (test) {
 
         // http://en.wikipedia.org/wiki/ISO_week
         var cases = {
@@ -211,22 +211,22 @@ exports.format = {
             "2010-01-01": "2009-53",
             "2010-01-02": "2009-53",
             "2010-01-03": "2009-53"
-        };
+        }, i, isoWeekYear, formatted5, formatted4, formatted2;
 
-        for (var i in cases) {
-            var isoWeekYear = cases[i].split('-')[0];
-            var formatted5 = moment(i).format('GGGGG');
+        for (i in cases) {
+            isoWeekYear = cases[i].split('-')[0];
+            formatted5 = moment(i).format('GGGGG');
             test.equal('0' + isoWeekYear, formatted5, i + ": should be " + isoWeekYear + ", but " + formatted4);
-            var formatted4 = moment(i).format('GGGG');
+            formatted4 = moment(i).format('GGGG');
             test.equal(isoWeekYear, formatted4, i + ": should be " + isoWeekYear + ", but " + formatted4);
-            var formatted2 = moment(i).format('GG');
+            formatted2 = moment(i).format('GG');
             test.equal(isoWeekYear.slice(2, 4), formatted2, i + ": should be " + isoWeekYear + ", but " + formatted2);
         }
 
         test.done();
     },
 
-    "week year formats" : function(test) {
+    "week year formats" : function (test) {
 
         // http://en.wikipedia.org/wiki/ISO_week
         var cases = {
@@ -245,23 +245,23 @@ exports.format = {
             "2010-01-01": "2009-53",
             "2010-01-02": "2009-53",
             "2010-01-03": "2009-53"
-        };
+        }, i, formatted5, formatted4, formatted2, isoWeekYear;
 
         moment.lang('en-gb'); // 1, 4
-        for (var i in cases) {
-            var isoWeekYear = cases[i].split('-')[0];
-            var formatted5 = moment(i).format('ggggg');
+        for (i in cases) {
+            isoWeekYear = cases[i].split('-')[0];
+            formatted5 = moment(i).format('ggggg');
             test.equal('0' + isoWeekYear, formatted5, i + ": should be " + isoWeekYear + ", but " + formatted4);
-            var formatted4 = moment(i).format('gggg');
+            formatted4 = moment(i).format('gggg');
             test.equal(isoWeekYear, formatted4, i + ": should be " + isoWeekYear + ", but " + formatted4);
-            var formatted2 = moment(i).format('gg');
+            formatted2 = moment(i).format('gg');
             test.equal(isoWeekYear.slice(2, 4), formatted2, i + ": should be " + isoWeekYear + ", but " + formatted2);
         }
 
         test.done();
     },
 
-    "iso weekday formats" : function(test) {
+    "iso weekday formats" : function (test) {
         test.expect(7);
 
         test.equal(moment([1985, 1,  4]).format('E'), '1', "Feb  4 1985 is Monday    -- 1st day");
@@ -275,10 +275,10 @@ exports.format = {
         test.done();
     },
 
-    "weekday formats" : function(test) {
+    "weekday formats" : function (test) {
         test.expect(7);
 
-        moment.lang('dow:3,doy:5', {week: {dow: 3, doy: 5}});
+        moment.lang('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
         test.equal(moment([1985, 1,  6]).format('e'), '0', "Feb  6 1985 is Wednesday -- 0th day");
         test.equal(moment([2029, 8, 20]).format('e'), '1', "Sep 20 2029 is Thursday  -- 1st day");
         test.equal(moment([2013, 3, 26]).format('e'), '2', "Apr 26 2013 is Friday    -- 2nd day");
@@ -290,7 +290,7 @@ exports.format = {
         test.done();
     },
 
-    "toString is just human readable format" : function(test) {
+    "toString is just human readable format" : function (test) {
         test.expect(1);
 
         var b = moment(new Date(2009, 1, 5, 15, 25, 50, 125));
@@ -298,10 +298,10 @@ exports.format = {
         test.done();
     },
 
-    "toJSON skips postformat" : function(test) {
+    "toJSON skips postformat" : function (test) {
         test.expect(1);
 
-        moment.lang('postformat', {postformat: function(s) { s.replace(/./g, 'X') }});
+        moment.lang('postformat', {postformat: function (s) { s.replace(/./g, 'X'); }});
         test.equal(moment.utc([2000, 0, 1]).toJSON(), "2000-01-01T00:00:00.000Z", "toJSON doesn't postformat");
         test.done();
     }
index 2e79deb473345aa18fa23dd879b570e51053f5c2..49207b9502535454871ae0222b32db51e1ff17b5 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.getters_setters = {
-    "getters" : function(test) {
+    "getters" : function (test) {
         test.expect(8);
 
         var a = moment([2011, 9, 12, 6, 7, 8, 9]);
@@ -16,7 +16,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "setters plural" : function(test) {
+    "setters plural" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -38,7 +38,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "setters singular" : function(test) {
+    "setters singular" : function (test) {
         test.expect(8);
 
         var a = moment();
@@ -60,7 +60,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "setters" : function(test) {
+    "setters" : function (test) {
         test.expect(9);
 
         var a = moment();
@@ -88,7 +88,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "setters strings" : function(test) {
+    "setters strings" : function (test) {
         test.expect(7);
 
         var a = moment([2012]).lang('en');
@@ -102,7 +102,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "setters - falsey values" : function(test) {
+    "setters - falsey values" : function (test) {
         test.expect(1);
 
         var a = moment();
@@ -113,7 +113,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "chaining setters" : function(test) {
+    "chaining setters" : function (test) {
         test.expect(7);
 
         var a = moment();
@@ -133,7 +133,7 @@ exports.getters_setters = {
         test.done();
     },
 
-    "day setter" : function(test) {
+    "day setter" : function (test) {
         test.expect(18);
 
         var a = moment([2011, 0, 15]);
index 59c02e3ef9c6f88e5d86a839dfb960e0c9eb2d47..7991132b4bdddee3f396afed06f61e6c5578a083 100644 (file)
@@ -1,31 +1,31 @@
 var moment = require("../../moment");
 
 exports.is_after = {
-    "is after without units" : function(test) {
+    "is after without units" : function (test) {
         test.expect(17);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
-    test.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, "year is later");
-    test.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), true, "year is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, "month is later");
-    test.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), true, "month is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, "day is later");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), true, "day is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, "hour is later");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), true, "hour is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, "minute is later");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), true, "minute is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, "second is later");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), true, "second is earlier");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, "millisecond match");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, "millisecond is later");
-    test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), true, "millisecond is earlier");
+        test.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, "year is later");
+        test.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), true, "year is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, "month is later");
+        test.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), true, "month is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, "day is later");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), true, "day is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, "hour is later");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), true, "hour is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, "minute is later");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), true, "minute is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, "second is later");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), true, "second is earlier");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, "millisecond match");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, "millisecond is later");
+        test.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), true, "millisecond is earlier");
         test.equal(m.isAfter(m), false, "moments are not after themselves");
         test.equal(+m, +mCopy, "isAfter second should not change moment");
         test.done();
     },
 
-    "is after year" : function(test) {
+    "is after year" : function (test) {
         test.expect(11);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -43,7 +43,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after month" : function(test) {
+    "is after month" : function (test) {
         test.expect(13);
 
         var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
@@ -63,7 +63,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after day" : function(test) {
+    "is after day" : function (test) {
         test.expect(15);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -85,7 +85,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after hour" : function(test) {
+    "is after hour" : function (test) {
         test.expect(16);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -108,7 +108,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after minute" : function(test) {
+    "is after minute" : function (test) {
         test.expect(18);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -133,7 +133,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after second" : function(test) {
+    "is after second" : function (test) {
         test.expect(20);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
@@ -160,7 +160,7 @@ exports.is_after = {
         test.done();
     },
 
-    "is after millisecond" : function(test) {
+    "is after millisecond" : function (test) {
         test.expect(18);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
index 0e0efb53eeb652957e0cb697050a801556f885f0..c3b0a4fe7ba3de10c17d11d533ddd24621d1b3fd 100644 (file)
@@ -1,31 +1,31 @@
 var moment = require("../../moment");
 
 exports.is_before = {
-    "is after without units" : function(test) {
+    "is after without units" : function (test) {
         test.expect(17);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
-    test.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), true, "year is later");
-    test.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, "year is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, "month is later");
-    test.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, "month is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, "day is later");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, "day is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, "hour is later");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, "hour is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, "minute is later");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, "minute is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, "second is later");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, "second is earlier");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, "millisecond match");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, "millisecond is later");
-    test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, "millisecond is earlier");
+        test.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), true, "year is later");
+        test.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, "year is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, "month is later");
+        test.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, "month is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, "day is later");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, "day is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, "hour is later");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, "hour is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, "minute is later");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, "minute is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, "second is later");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, "second is earlier");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, "millisecond match");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, "millisecond is later");
+        test.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, "millisecond is earlier");
         test.equal(m.isBefore(m), false, "moments are not before themselves");
         test.equal(+m, +mCopy, "isBefore second should not change moment");
         test.done();
     },
 
-    "is before year" : function(test) {
+    "is before year" : function (test) {
         test.expect(11);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -43,7 +43,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before month" : function(test) {
+    "is before month" : function (test) {
         test.expect(13);
 
         var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
@@ -63,7 +63,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before day" : function(test) {
+    "is before day" : function (test) {
         test.expect(15);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -85,7 +85,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before hour" : function(test) {
+    "is before hour" : function (test) {
         test.expect(16);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -108,7 +108,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before minute" : function(test) {
+    "is before minute" : function (test) {
         test.expect(18);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -133,7 +133,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before second" : function(test) {
+    "is before second" : function (test) {
         test.expect(20);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
@@ -160,7 +160,7 @@ exports.is_before = {
         test.done();
     },
 
-    "is before millisecond" : function(test) {
+    "is before millisecond" : function (test) {
         test.expect(18);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
index 9b085cc1d463d7ea45458a14b18060fedcb51ef2..1fb49bcdadb77fe48aab43b3273ebabe207d8746 100644 (file)
@@ -1,13 +1,13 @@
 var moment = require('../../moment');
 
 exports.is_moment = {
-    "is moment object": function(test) {
+    "is moment object": function (test) {
         test.expect(11);
 
-        var MyObj = function() {};
-        MyObj.prototype.toDate = function() {
+        var MyObj = function () {};
+        MyObj.prototype.toDate = function () {
             return new Date();
-        }
+        };
 
         test.ok(moment.isMoment(moment()), 'simple moment object');
         test.ok(moment.isMoment(moment('invalid date')), 'invalid moment object');
index bd9a792b68c7115198f452dfb7dc954e744933cf..108141669c32284b5be312069e55ba4af1f4817c 100644 (file)
@@ -1,31 +1,31 @@
 var moment = require("../../moment");
 
 exports.is_same = {
-    "is same without units" : function(test) {
+    "is same without units" : function (test) {
         test.expect(17);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
-    test.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, "year is later");
-    test.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, "year is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, "month is later");
-    test.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, "month is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, "day is later");
-    test.equal(m.isSame(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, "day is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, "hour is later");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, "hour is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, "minute is later");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, "minute is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, "second is later");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, "second is earlier");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), true, "millisecond match");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, "millisecond is later");
-    test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, "millisecond is earlier");
+        test.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, "year is later");
+        test.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, "year is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, "month is later");
+        test.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, "month is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, "day is later");
+        test.equal(m.isSame(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, "day is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, "hour is later");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, "hour is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, "minute is later");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, "minute is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, "second is later");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, "second is earlier");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), true, "millisecond match");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, "millisecond is later");
+        test.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, "millisecond is earlier");
         test.equal(m.isSame(m), true, "moments are the same as themselves");
         test.equal(+m, +mCopy, "isSame second should not change moment");
         test.done();
     },
 
-    "is same year" : function(test) {
+    "is same year" : function (test) {
         test.expect(9);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -41,7 +41,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same month" : function(test) {
+    "is same month" : function (test) {
         test.expect(10);
 
         var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
@@ -58,7 +58,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same day" : function(test) {
+    "is same day" : function (test) {
         test.expect(11);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -76,7 +76,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same hour" : function(test) {
+    "is same hour" : function (test) {
         test.expect(12);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -95,7 +95,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same minute" : function(test) {
+    "is same minute" : function (test) {
         test.expect(13);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -115,7 +115,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same second" : function(test) {
+    "is same second" : function (test) {
         test.expect(14);
 
         var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
@@ -136,7 +136,7 @@ exports.is_same = {
         test.done();
     },
 
-    "is same millisecond" : function(test) {
+    "is same millisecond" : function (test) {
         test.expect(18);
 
         var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
index a0e2b6028f6896e8500c7f47c468ad6da2bf8d6c..33b9d653bf5aa2237096b37cc7ca0761166395af 100644 (file)
@@ -109,11 +109,11 @@ exports.is_valid = {
             '2010-01-01T24',
             '2010-01-01T23:60',
             '2010-01-01T23:59:60'
-        ];
+        ], i;
 
         test.expect(tests.length * 2);
 
-        for (var i = 0; i < tests.length; i++) {
+        for (i = 0; i < tests.length; i++) {
             test.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
             test.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
         }
@@ -130,11 +130,11 @@ exports.is_valid = {
             '2010-01-40T23:60+00:00',
             '2010-01-40T23:59:60+00:00',
             '2010-01-40T23:59:59.9999+00:00'
-        ];
+        ], i;
 
         test.expect(tests.length * 2);
 
-        for (var i = 0; i < tests.length; i++) {
+        for (i = 0; i < tests.length; i++) {
             test.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
             test.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
         }
@@ -151,11 +151,11 @@ exports.is_valid = {
             '2010-01-30T23:59:59.999+00:00',
             '2010-01-30T23:59:59.999-07:00',
             '2010-01-30T00:00:00.000+07:00'
-        ];
+        ], i;
 
         test.expect(tests.length * 2);
 
-        for (var i = 0; i < tests.length; i++) {
+        for (i = 0; i < tests.length; i++) {
             test.equal(moment(tests[i]).isValid(), true, tests[i] + ' should be valid');
             test.equal(moment.utc(tests[i]).isValid(), true, tests[i] + ' should be valid');
         }
index 7a3dd263c43e2cd7548b16affe16592f3d859b54..84d67abaebdd19dcc805110891f4262d44703e39 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.leapyear = {
-    "leap year" : function(test) {
+    "leap year" : function (test) {
         test.expect(4);
 
         test.equal(moment([2010, 0, 1]).isLeapYear(), false, '2010');
index fdc76731c9db305dd7fca0574a92e63382edc7e0..ea46b937f64c7ee80e4d16da3cd50929158344bf 100644 (file)
@@ -4,28 +4,28 @@ exports.mutable = {
     "manipulation methods" : function (test) {
 
         var mutableMethods = {
-            'year':          function (m){ return m.year(2011); },
-            'month':         function (m){ return m.month(1); },
-            'date':          function (m){ return m.date(9); },
-            'hours':         function (m){ return m.hours(7); },
-            'minutes':       function (m){ return m.minutes(33); },
-            'seconds':       function (m){ return m.seconds(44); },
-            'milliseconds':  function (m){ return m.milliseconds(55); },
-            'day':           function (m){ return m.day(2); },
-            'startOf':       function (m){ return m.startOf('week') },
-            'endOf':         function (m){ return m.endOf('week') },
-            'add':           function (m){ return m.add('days', 1) },
-            'subtract':      function (m){ return m.subtract('years', 2) },
-            'local':         function (m){ return m.local() },
-            'utc':           function (m){ return m.utc() }
-        };
+            'year':          function (m) { return m.year(2011); },
+            'month':         function (m) { return m.month(1); },
+            'date':          function (m) { return m.date(9); },
+            'hours':         function (m) { return m.hours(7); },
+            'minutes':       function (m) { return m.minutes(33); },
+            'seconds':       function (m) { return m.seconds(44); },
+            'milliseconds':  function (m) { return m.milliseconds(55); },
+            'day':           function (m) { return m.day(2); },
+            'startOf':       function (m) { return m.startOf('week'); },
+            'endOf':         function (m) { return m.endOf('week'); },
+            'add':           function (m) { return m.add('days', 1); },
+            'subtract':      function (m) { return m.subtract('years', 2); },
+            'local':         function (m) { return m.local(); },
+            'utc':           function (m) { return m.utc(); }
+        }, method, d, d2;
 
         test.expect(14);
 
         for (method in mutableMethods) {
             if (mutableMethods.hasOwnProperty(method)) {
-                var d = moment();
-                var d2 = mutableMethods[method](d);
+                d = moment();
+                d2 = mutableMethods[method](d);
                 test.equal(d, d2, method + "() should be mutable");
             }
         }
@@ -36,15 +36,15 @@ exports.mutable = {
     "non mutable methods" : function (test) {
 
         var nonMutableMethods = {
-            'clone':       function (m){ return m.clone() }
-        };
+            'clone':       function (m) { return m.clone(); }
+        }, method, d, d2;
 
         test.expect(1);
 
-        for (method in nonMutableMethods){
+        for (method in nonMutableMethods) {
             if (nonMutableMethods.hasOwnProperty(method)) {
-                var d = new Date();
-                var d2 = nonMutableMethods[method](moment(d)).toDate();
+                d = new Date();
+                d2 = nonMutableMethods[method](moment(d)).toDate();
                 test.notEqual(d, d2, method + "() should not be mutable");
             }
         }
index d3dcc2dad39668138585dfa0af7a99edb18e1ab2..b7dd8f1ce7204fc676677a2c086f751a2cb99c54 100644 (file)
@@ -2,57 +2,57 @@ var moment = require("../../moment");
 
 
 var symbolMap = {
-  '1': '!',
-  '2': '@',
-  '3': '#',
-  '4': '$',
-  '5': '%',
-  '6': '^',
-  '7': '&',
-  '8': '*',
-  '9': '(',
-  '0': ')'
+    '1': '!',
+    '2': '@',
+    '3': '#',
+    '4': '$',
+    '5': '%',
+    '6': '^',
+    '7': '&',
+    '8': '*',
+    '9': '(',
+    '0': ')'
 };
 
 var numberMap = {
-  '!': '1',
-  '@': '2',
-  '#': '3',
-  '$': '4',
-  '%': '5',
-  '^': '6',
-  '&': '7',
-  '*': '8',
-  '(': '9',
-  ')': '0'
+    '!': '1',
+    '@': '2',
+    '#': '3',
+    '$': '4',
+    '%': '5',
+    '^': '6',
+    '&': '7',
+    '*': '8',
+    '(': '9',
+    ')': '0'
 };
 
 var symbolLang = {
-    preparse: function(string) {
-        return string.replace(/[!@#$%\^&*()]/g, function(match) {
+    preparse: function (string) {
+        return string.replace(/[!@#$%\^&*()]/g, function (match) {
             return numberMap[match];
         });
     },
 
-    postformat: function(string) {
-        return string.replace(/\d/g, function(match) {
+    postformat: function (string) {
+        return string.replace(/\d/g, function (match) {
             return symbolMap[match];
         });
     }
 };
 
 exports.preparse_postformat = {
-    setUp: function(cb) {
+    setUp: function (cb) {
         moment.lang('symbol', symbolLang);
         cb();
     },
 
-    tearDown: function(cb) {
+    tearDown: function (cb) {
         moment.lang('en-gb');
         cb();
     },
 
-    "transform": function(test) {
+    "transform": function (test) {
         test.expect(3);
 
         test.equal(moment.utc('@)!@-)*-@&', 'YYYY-MM-DD').unix(), 1346025600, "preparse string + format");
@@ -62,19 +62,19 @@ exports.preparse_postformat = {
         test.done();
     },
 
-    "transform from": function(test) {
+    "transform from": function (test) {
         test.expect(3);
 
         var start = moment([2007, 1, 28]);
 
-        test.equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "@ minutes", "postformat should work on moment.fn.from");
+        test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "@ minutes", "postformat should work on moment.fn.from");
         test.equal(moment().add('d', 6).fromNow(true), "^ days", "postformat should work on moment.fn.fromNow");
         test.equal(moment.duration(10, "h").humanize(), "!) hours", "postformat should work on moment.duration.fn.humanize");
 
         test.done();
     },
 
-    "calendar day" : function(test) {
+    "calendar day" : function (test) {
         test.expect(6);
 
         var a = moment().hours(2).minutes(0).seconds(0);
index 98338b968883d33d708a75989f64cf9c60727d6c..164ad82b898cb15cef82e4cf6fd3e09cac0dd208 100644 (file)
@@ -11,12 +11,12 @@ exports.end_start_of = {
         cb();
     },
 
-    "start of year" : function(test) {
+    "start of year" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('year');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('years');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('y');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('year'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('years'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('y');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -29,12 +29,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of year" : function(test) {
+    "end of year" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('year');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('years');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('y');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('year'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('years'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('y');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -47,12 +47,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of month" : function(test) {
+    "start of month" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('month');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('months');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('M');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('month'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('months'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('M');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -65,12 +65,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of month" : function(test) {
+    "end of month" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('month');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('months');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('M');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('month'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('months'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('M');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -83,12 +83,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of week" : function(test) {
+    "start of week" : function (test) {
         test.expect(10);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('week');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('weeks');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('w');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('week'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('weeks'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('w');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -102,12 +102,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of week" : function(test) {
+    "end of week" : function (test) {
         test.expect(10);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('week');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('week'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -121,12 +121,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of day" : function(test) {
+    "start of day" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('day');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('days');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('d');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('day'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('days'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('d');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -139,12 +139,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of day" : function(test) {
+    "end of day" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('day');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('days');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('d');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('day'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('days'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('d');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -157,12 +157,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of hour" : function(test) {
+    "start of hour" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hours');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('h');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hours'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('h');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -175,12 +175,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of hour" : function(test) {
+    "end of hour" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hour');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hours');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('h');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hour'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hours'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('h');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -193,12 +193,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of minute" : function(test) {
+    "start of minute" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minute');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minutes');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('m');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minute'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minutes'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('m');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -211,12 +211,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of minute" : function(test) {
+    "end of minute" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minute');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minutes');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('m');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minute'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minutes'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('m');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
@@ -229,14 +229,14 @@ exports.end_start_of = {
         test.done();
     },
 
-    "start of second" : function(test) {
+    "start of second" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('second');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('seconds');
-               var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('s');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('second'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('seconds'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('s');
         test.equal(+m, +ms, "Plural or singular should work");
-               test.equal(+m, +ma, "Full or abbreviated should work");
+        test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
         test.equal(m.month(), 1, "keep the month");
         test.equal(m.date(), 2, "keep the day");
@@ -247,12 +247,12 @@ exports.end_start_of = {
         test.done();
     },
 
-    "end of second" : function(test) {
+    "end of second" : function (test) {
         test.expect(9);
 
-        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('second');
-        var ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('seconds');
-        var ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('s');
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('second'),
+            ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('seconds'),
+            ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('s');
         test.equal(+m, +ms, "Plural or singular should work");
         test.equal(+m, +ma, "Full or abbreviated should work");
         test.equal(m.year(), 2011, "keep the year");
index d4712d1fcd9a7afd83779bdba09cb4ad83027499..341552a714fe17edcb72d59bdae795b6630afb8a 100644 (file)
@@ -1,13 +1,13 @@
 var moment = require("../../moment");
 
 exports.add = {
-    "string prototype overrides call" : function(test) {
+    "string prototype overrides call" : function (test) {
         test.expect(1);
 
-        var prior = String.prototype.call;
-        String.prototype.call = function() { return null;};
+        var prior = String.prototype.call, b;
+        String.prototype.call = function () { return null; };
 
-        var b = moment(new Date(2011, 7, 28, 15, 25, 50, 125));
+        b = moment(new Date(2011, 7, 28, 15, 25, 50, 125));
         test.equal(b.format('MMMM Do YYYY, h:mm a'), 'August 28th 2011, 3:25 pm');
 
         String.prototype.call = prior;
index a064ee02b88b22f6bb0c1ad24ae47d73fb5ef77f..7fb1109c886c16cad98a9a821c628b4fa1b6c9df 100644 (file)
@@ -11,10 +11,10 @@ exports.utc = {
         cb();
     },
 
-    "utc and local" : function(test) {
+    "utc and local" : function (test) {
         test.expect(7);
 
-        var m = moment(Date.UTC(2011, 1, 2, 3, 4, 5, 6));
+        var m = moment(Date.UTC(2011, 1, 2, 3, 4, 5, 6)), zone, expected;
         m.utc();
         // utc
         test.equal(m.date(), 2, "the day should be correct for utc");
@@ -30,23 +30,23 @@ 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 zone = Math.ceil(m.zone() / 60);
-        var expected = (24 + 3 - zone) % 24;
+        zone = Math.ceil(m.zone() / 60);
+        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();
     },
 
-    "creating with utc" : function(test) {
+    "creating with utc" : function (test) {
         test.expect(7);
 
-        var diff = moment.utc().valueOf() - moment().valueOf();
+        var diff = moment.utc().valueOf() - moment().valueOf(), m;
         diff = Math.abs(diff);
         // we check the diff rather than equality because sometimes they are off by a millisecond
 
         test.ok(diff < 5, "Calling moment.utc() should default to the current time");
 
-        var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
+        m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
         test.equal(m.date(), 2, "the day should be correct for utc array");
         test.equal(m.hours(), 3, "the hours should be correct for utc array");
 
@@ -61,7 +61,7 @@ exports.utc = {
         test.done();
     },
 
-    "creating with utc without timezone" : function(test) {
+    "creating with utc without timezone" : function (test) {
         test.expect(4);
 
         var m = moment.utc("2012-01-02T08:20:00");
index 185e5240ebd2cc0b05eb1d6584fa6e6e03ae2bee..345c3862c41d6a77dfaebb59ba06f489b0010c1e 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
 exports.week_year = {
-    "iso week year": function(test) {
+    "iso week year": function (test) {
         test.expect(19);
 
         // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
@@ -28,11 +28,11 @@ exports.week_year = {
         test.done();
     },
 
-    "week year": function(test) {
+    "week year": function (test) {
         test.expect(31);
 
         // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
-        moment.lang('dow:1,doy:4', {week: {dow: 1, doy: 4}}); // like iso
+        moment.lang('dow: 1,doy: 4', {week: {dow: 1, doy: 4}}); // like iso
         test.equal(moment([2005, 0, 1]).weekYear(), 2004);
         test.equal(moment([2005, 0, 2]).weekYear(), 2004);
         test.equal(moment([2005, 0, 3]).weekYear(), 2005);
@@ -53,7 +53,7 @@ exports.week_year = {
         test.equal(moment([2010, 0, 3]).weekYear(), 2009);
         test.equal(moment([2010, 0, 4]).weekYear(), 2010);
 
-        moment.lang('dow:1,doy:7', {week: {dow: 1, doy: 7}});
+        moment.lang('dow: 1,doy: 7', {week: {dow: 1, doy: 7}});
         test.equal(moment([2004, 11, 26]).weekYear(), 2004);
         test.equal(moment([2004, 11, 27]).weekYear(), 2005);
         test.equal(moment([2005, 11, 25]).weekYear(), 2005);
index ef1571e341b9bc04389f97fc3b608748b8d1df18..c04fb2f84687e62b98ee1b98bf7aa064d2019fa6 100644 (file)
@@ -1,12 +1,12 @@
 var moment = require("../../moment");
 
 exports.week_year = {
-    "iso weekday": function(test) {
+    "iso weekday": function (test) {
         var i;
         test.expect(7 * 7);
 
         for (i = 0; i < 7; ++i) {
-            moment.lang('dow:' + i + ',doy:6', {week: {dow: i, doy: 6}});
+            moment.lang('dow:' + i + ',doy: 6', {week: {dow: i, doy: 6}});
             test.equal(moment([1985, 1,  4]).isoWeekday(), 1, "Feb  4 1985 is Monday    -- 1st day");
             test.equal(moment([2029, 8, 18]).isoWeekday(), 2, "Sep 18 2029 is Tuesday   -- 2nd day");
             test.equal(moment([2013, 3, 24]).isoWeekday(), 3, "Apr 24 2013 is Wednesday -- 3rd day");
@@ -18,7 +18,7 @@ exports.week_year = {
         test.done();
     },
 
-    "iso weekday setter" : function(test) {
+    "iso weekday setter" : function (test) {
         test.expect(27);
 
         var a = moment([2011, 0, 10]);
@@ -57,10 +57,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Sunday (dow 0)": function(test) {
+    "weekday first day of week Sunday (dow 0)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:0,doy:6', {week: {dow: 0, doy: 6}});
+        moment.lang('dow: 0,doy: 6', {week: {dow: 0, doy: 6}});
         test.equal(moment([1985, 1,  3]).weekday(), 0, "Feb  3 1985 is Sunday    -- 0th day");
         test.equal(moment([2029, 8, 17]).weekday(), 1, "Sep 17 2029 is Monday    -- 1st day");
         test.equal(moment([2013, 3, 23]).weekday(), 2, "Apr 23 2013 is Tuesday   -- 2nd day");
@@ -71,10 +71,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Monday (dow 1)": function(test) {
+    "weekday first day of week Monday (dow 1)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:1,doy:6', {week: {dow: 1, doy: 6}});
+        moment.lang('dow: 1,doy: 6', {week: {dow: 1, doy: 6}});
         test.equal(moment([1985, 1,  4]).weekday(), 0, "Feb  4 1985 is Monday    -- 0th day");
         test.equal(moment([2029, 8, 18]).weekday(), 1, "Sep 18 2029 is Tuesday   -- 1st day");
         test.equal(moment([2013, 3, 24]).weekday(), 2, "Apr 24 2013 is Wednesday -- 2nd day");
@@ -85,10 +85,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Tuesday (dow 2)": function(test) {
+    "weekday first day of week Tuesday (dow 2)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:2,doy:6', {week: {dow: 2, doy: 6}});
+        moment.lang('dow: 2,doy: 6', {week: {dow: 2, doy: 6}});
         test.equal(moment([1985, 1,  5]).weekday(), 0, "Feb  5 1985 is Tuesday   -- 0th day");
         test.equal(moment([2029, 8, 19]).weekday(), 1, "Sep 19 2029 is Wednesday -- 1st day");
         test.equal(moment([2013, 3, 25]).weekday(), 2, "Apr 25 2013 is Thursday  -- 2nd day");
@@ -99,10 +99,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Wednesday (dow 3)": function(test) {
+    "weekday first day of week Wednesday (dow 3)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:3,doy:6', {week: {dow: 3, doy: 6}});
+        moment.lang('dow: 3,doy: 6', {week: {dow: 3, doy: 6}});
         test.equal(moment([1985, 1,  6]).weekday(), 0, "Feb  6 1985 is Wednesday -- 0th day");
         test.equal(moment([2029, 8, 20]).weekday(), 1, "Sep 20 2029 is Thursday  -- 1st day");
         test.equal(moment([2013, 3, 26]).weekday(), 2, "Apr 26 2013 is Friday    -- 2nd day");
@@ -113,10 +113,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Thursday (dow 4)": function(test) {
+    "weekday first day of week Thursday (dow 4)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:4,doy:6', {week: {dow: 4, doy: 6}});
+        moment.lang('dow: 4,doy: 6', {week: {dow: 4, doy: 6}});
 
         test.equal(moment([1985, 1,  7]).weekday(), 0, "Feb  7 1985 is Thursday  -- 0th day");
         test.equal(moment([2029, 8, 21]).weekday(), 1, "Sep 21 2029 is Friday    -- 1st day");
@@ -128,10 +128,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Friday (dow 5)": function(test) {
+    "weekday first day of week Friday (dow 5)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:5,doy:6', {week: {dow: 5, doy: 6}});
+        moment.lang('dow: 5,doy: 6', {week: {dow: 5, doy: 6}});
         test.equal(moment([1985, 1,  8]).weekday(), 0, "Feb  8 1985 is Friday    -- 0th day");
         test.equal(moment([2029, 8, 22]).weekday(), 1, "Sep 22 2029 is Staturday -- 1st day");
         test.equal(moment([2013, 3, 28]).weekday(), 2, "Apr 28 2013 is Sunday    -- 2nd day");
@@ -142,10 +142,10 @@ exports.week_year = {
         test.done();
     },
 
-    "weekday first day of week Saturday (dow 6)": function(test) {
+    "weekday first day of week Saturday (dow 6)": function (test) {
         test.expect(7);
 
-        moment.lang('dow:6,doy:6', {week: {dow: 6, doy: 6}});
+        moment.lang('dow: 6,doy: 6', {week: {dow: 6, doy: 6}});
         test.equal(moment([1985, 1,  9]).weekday(), 0, "Feb  9 1985 is Staturday -- 0th day");
         test.equal(moment([2029, 8, 23]).weekday(), 1, "Sep 23 2029 is Sunday    -- 1st day");
         test.equal(moment([2013, 3, 29]).weekday(), 2, "Apr 29 2013 is Monday    -- 2nd day");
index 1b8b38399ce74c5a533b8cdfb65ac2d235f65103..e45b9c0671661fd97bbb18a5ad06c40609c9eeb7 100644 (file)
@@ -33,15 +33,15 @@ exports.weeks = {
         test.equal(moment([2000,  1, 28]).dayOfYear(200).dayOfYear(), 200, "Setting Feb 28 2000 day of the year to 200 should work");
         test.equal(moment([2000,  1, 29]).dayOfYear(200).dayOfYear(), 200, "Setting Feb 28 2000 day of the year to 200 should work");
         test.equal(moment([2000, 11, 31]).dayOfYear(200).dayOfYear(), 200, "Setting Dec 31 2000 day of the year to 200 should work");
-        test.equal(moment().dayOfYear(  1).dayOfYear(),   1, "Setting day of the year to 1 should work");
-        test.equal(moment().dayOfYear( 59).dayOfYear(),  59, "Setting day of the year to 59 should work");
-        test.equal(moment().dayOfYear( 60).dayOfYear(),  60, "Setting day of the year to 60 should work");
+        test.equal(moment().dayOfYear(1).dayOfYear(),   1, "Setting day of the year to 1 should work");
+        test.equal(moment().dayOfYear(59).dayOfYear(),  59, "Setting day of the year to 59 should work");
+        test.equal(moment().dayOfYear(60).dayOfYear(),  60, "Setting day of the year to 60 should work");
         test.equal(moment().dayOfYear(365).dayOfYear(), 365, "Setting day of the year to 365 should work");
 
         test.done();
     },
 
-    "iso weeks year starting sunday" : function(test) {
+    "iso weeks year starting sunday" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0, 1]).isoWeek(), 52, "Jan  1 2012 should be iso week 52");
@@ -53,7 +53,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting monday" : function(test) {
+    "iso weeks year starting monday" : function (test) {
         test.expect(5);
 
         test.equal(moment([2007, 0, 1]).isoWeek(),  1, "Jan  1 2007 should be iso week 1");
@@ -65,7 +65,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting tuesday" : function(test) {
+    "iso weeks year starting tuesday" : function (test) {
         test.expect(6);
 
         test.equal(moment([2007, 11, 31]).isoWeek(), 1, "Dec 31 2007 should be iso week 1");
@@ -78,7 +78,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting wednesday" : function(test) {
+    "iso weeks year starting wednesday" : function (test) {
         test.expect(6);
 
         test.equal(moment([2002, 11, 30]).isoWeek(), 1, "Dec 30 2002 should be iso week 1");
@@ -91,7 +91,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting thursday" : function(test) {
+    "iso weeks year starting thursday" : function (test) {
         test.expect(6);
 
         test.equal(moment([2008, 11, 29]).isoWeek(), 1, "Dec 29 2008 should be iso week 1");
@@ -104,7 +104,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting friday" : function(test) {
+    "iso weeks year starting friday" : function (test) {
         test.expect(6);
 
         test.equal(moment([2009, 11, 28]).isoWeek(), 53, "Dec 28 2009 should be iso week 53");
@@ -117,7 +117,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting saturday" : function(test) {
+    "iso weeks year starting saturday" : function (test) {
         test.expect(6);
 
         test.equal(moment([2010, 11, 27]).isoWeek(), 52, "Dec 27 2010 should be iso week 52");
@@ -130,19 +130,19 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks year starting sunday formatted" : function(test) {
+    "iso weeks year starting sunday formatted" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0,  1]).format('W WW Wo'), '52 52 52nd', "Jan  1 2012 should be iso week 52");
-        test.equal(moment([2012, 0,  2]).format('W WW Wo'),  '1 01 1st' , "Jan  2 2012 should be iso week 1");
-        test.equal(moment([2012, 0,  8]).format('W WW Wo'),  '1 01 1st' , "Jan  8 2012 should be iso week 1");
-        test.equal(moment([2012, 0,  9]).format('W WW Wo'),  '2 02 2nd' , "Jan  9 2012 should be iso week 2");
-        test.equal(moment([2012, 0, 15]).format('W WW Wo'),  '2 02 2nd' , "Jan 15 2012 should be iso week 2");
+        test.equal(moment([2012, 0,  2]).format('W WW Wo'),   '1 01 1st', "Jan  2 2012 should be iso week 1");
+        test.equal(moment([2012, 0,  8]).format('W WW Wo'),   '1 01 1st', "Jan  8 2012 should be iso week 1");
+        test.equal(moment([2012, 0,  9]).format('W WW Wo'),   '2 02 2nd', "Jan  9 2012 should be iso week 2");
+        test.equal(moment([2012, 0, 15]).format('W WW Wo'),   '2 02 2nd', "Jan 15 2012 should be iso week 2");
 
         test.done();
     },
 
-    "weeks plural year starting sunday" : function(test) {
+    "weeks plural year starting sunday" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0,  1]).weeks(), 1, "Jan  1 2012 should be week 1");
@@ -154,7 +154,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks plural year starting sunday" : function(test) {
+    "iso weeks plural year starting sunday" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0, 1]).isoWeeks(), 52, "Jan  1 2012 should be iso week 52");
@@ -166,7 +166,7 @@ exports.weeks = {
         test.done();
     },
 
-    "weeks setter" : function(test) {
+    "weeks setter" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0,  1]).week(30).week(), 30, "Setting Jan 1 2012 to week 30 should work");
@@ -178,7 +178,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks setter" : function(test) {
+    "iso weeks setter" : function (test) {
         test.expect(5);
 
         test.equal(moment([2012, 0,  1]).isoWeeks(25).isoWeeks(), 25, "Setting Jan  1 2012 to week 25 should work");
@@ -190,7 +190,7 @@ exports.weeks = {
         test.done();
     },
 
-    "iso weeks setter day of year" : function(test) {
+    "iso weeks setter day of year" : function (test) {
         test.expect(6);
 
         test.equal(moment([2012, 0,  1]).isoWeek(1).dayOfYear(), 9, "Setting Jan  1 2012 to week 1 should be day of year 8");