// 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);
/**************************************************
Tests
*************************************************/
-
+
module("create");
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)