]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Improve dateFromObject to utilise the normalizedUnits method. 1103/head
authorXotic750 <xotic750@gmail.com>
Mon, 16 Sep 2013 16:02:34 +0000 (18:02 +0200)
committerXotic750 <xotic750@gmail.com>
Mon, 16 Sep 2013 16:02:34 +0000 (18:02 +0200)
User object will now handle any acceptable capitalisation, aliasing or pluralisation.

moment.js

index 34f22fcc2f56aaecda38b1beb6ba1bb90bd1b38e..de252f8031533d0dc539708f32d330f896ddba61 100644 (file)
--- a/moment.js
+++ b/moment.js
     }
 
     function dateFromObject(config) {
-        var o = config._i;
+        var normalizedInput = {},
+            normalizedProp,
+            prop,
+            index;
 
         if (config._d) {
             return;
         }
 
+        for (prop in config._i) {
+            if (config._i.hasOwnProperty(prop)) {
+                normalizedProp = normalizeUnits(prop);
+                if (normalizedProp) {
+                    normalizedInput[normalizedProp] = config._i[prop];
+                }
+            }
+        }
+
         config._a = [
-            o.years || o.year || o.y,
-            o.months || o.month || o.M,
-            o.days || o.day || o.d,
-            o.hours || o.hour || o.h,
-            o.minutes || o.minute || o.m,
-            o.seconds || o.second || o.s,
-            o.milliseconds || o.millisecond || o.ms
+            normalizedInput.year,
+            normalizedInput.month,
+            normalizedInput.day,
+            normalizedInput.hour,
+            normalizedInput.minute,
+            normalizedInput.second,
+            normalizedInput.millisecond
         ];
 
         dateFromArray(config);