From 67c9506f4577c652cd1b4b05665219c0754ba3d0 Mon Sep 17 00:00:00 2001 From: Jordan Sexton Date: Wed, 30 Jul 2014 00:46:31 -0500 Subject: [PATCH] Allowing moment.set() to accept a hash of units --- moment.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/moment.js b/moment.js index 79b1e8b1c..e64ef0f67 100644 --- a/moment.js +++ b/moment.js @@ -2396,9 +2396,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; }, -- 2.47.2