]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Allowing moment.set() to accept a hash of units
authorJordan Sexton <jordan@jordansexton.com>
Wed, 30 Jul 2014 05:46:31 +0000 (00:46 -0500)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 24 Dec 2014 21:43:50 +0000 (13:43 -0800)
moment.js

index dbcfc400226535c0116d22e00b83443cdbb2b9f5..0dc4e070979954068b0def5aa54898d083d1554d 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         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;
         },