From: Jordan Sexton Date: Wed, 30 Jul 2014 05:46:31 +0000 (-0500) Subject: Allowing moment.set() to accept a hash of units X-Git-Tag: 2.9.0~17^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72f36a0d6cd19cb1bc7cf09629b0d7c6ed1e8672;p=thirdparty%2Fmoment.git Allowing moment.set() to accept a hash of units --- diff --git a/moment.js b/moment.js index dbcfc4002..0dc4e0709 100644 --- a/moment.js +++ b/moment.js @@ -2577,9 +2577,17 @@ }, set : function (units, value) { - units = normalizeUnits(units); - if (typeof this[units] === 'function') { - this[units](value); + var unit; + if (typeof units === 'object') { + for (unit in units) { + this.set(unit, units[unit]); + } + } + else { + units = normalizeUnits(units); + if (typeof this[units] === 'function') { + this[units](value); + } } return this; },