]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
setters - falsey values 31/head 32/head
authorBrad Dunbar <dunbarb2@gmail.com>
Mon, 24 Oct 2011 22:17:02 +0000 (18:17 -0400)
committerBrad Dunbar <dunbarb2@gmail.com>
Mon, 24 Oct 2011 22:17:02 +0000 (18:17 -0400)
moment.js
test/date.js

index e92398bdda54b94179ab40454ef707f4a4cbf41d..8aa9e83da7f20dcda5d27e0a10f99b7ef7eb53d2 100644 (file)
--- a/moment.js
+++ b/moment.js
     // helper for adding shortcuts
     function makeShortcut(name, key) {
         moment.fn[name] = function (input) {
-            if (input) {
+            if (input != null) {
                 this._d['set' + key](input);
                 return this;
             } else {
         window.moment = moment;
     }
 
-})(Date);
\ No newline at end of file
+})(Date);
index 1a73af1ed160a050c89dfd69735e176e65048852..a45b93587c1a0865947ca6cdf5c065d4db3549d4 100755 (executable)
@@ -12,7 +12,7 @@ if (typeof window === 'undefined') {
 /**************************************************
   Tests
  *************************************************/
+
 
 module("create");
 
@@ -227,6 +227,14 @@ test("setters", 7, function() {
     equal(a.seconds(), 8, 'second');
 });
 
+test("setters - falsey values", 1, function() {
+    var a = moment();
+    // ensure minutes wasn't coincidentally 0 already
+    a.minutes(1);
+    a.minutes(0);
+    equal(a.minutes(), 0, 'falsey value');
+});
+
 test("chaining setters", 7, function() {
     var a = moment();
     a.year(2011)