]> 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)
committerJordan Sexton <jordan@jordansexton.com>
Wed, 30 Jul 2014 05:46:31 +0000 (00:46 -0500)
moment.js

index 79b1e8b1ca56fe179d99e624dabcb905138d633d..e64ef0f67a3b68475f23ed1397c5bc6ac62bbd1d 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;
         },