]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
moment.utc() should use current time if no parameters were passed in.
authorTim Wood <washwithcare@gmail.com>
Mon, 30 Apr 2012 16:06:28 +0000 (09:06 -0700)
committerTim Wood <washwithcare@gmail.com>
Mon, 30 Apr 2012 16:06:28 +0000 (09:06 -0700)
#291

moment.js
test/moment/utc.js

index 6e7b5d9539654734267fca9e9bb42381da1efafc..0aacb218c8d77a71768127b3c3613783b8caabee 100644 (file)
--- a/moment.js
+++ b/moment.js
         }
         return (format && input) ?
             moment(input + ' +0000', format + ' Z').utc() :
-            moment(parseTokenTimezone.exec(input) ? input : input + '+0000').utc();
+            moment(input && !parseTokenTimezone.exec(input) ? input + '+0000' : input).utc();
     };
 
     // creating with unix timestamp (in seconds)
index 866bd54723651eaf86aa4485b58c6e129f023e69..c04805c11dfd23e5d44eb19c911f80ceecf0b73d 100644 (file)
@@ -28,7 +28,9 @@ exports.utc = {
     },
 
     "creating with utc" : function(test) {
-        test.expect(6);
+        test.expect(7);
+
+        test.equal(moment.utc().valueOf(), moment().valueOf(), "Calling moment.utc() should default to the current time");
 
         var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
         test.equal(m.date(), 2, "the day should be correct for utc array");