]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Moving to an internal `makeMoment` function for moment.utc() and moment()
authorTim Wood <washwithcare@gmail.com>
Fri, 26 Oct 2012 22:56:08 +0000 (15:56 -0700)
committerTim Wood <washwithcare@gmail.com>
Fri, 26 Oct 2012 22:56:08 +0000 (15:56 -0700)
#481

moment.js

index 0c77e8921411efcfec742f7e946b615b9aed89da..8dbfefda563b03a86547d8706eda5942d87b967c 100644 (file)
--- a/moment.js
+++ b/moment.js
         Top Level Functions
     ************************************/
 
+    function makeMoment(config) {
+        var input = config._i,
+            format = config._f;
 
-    moment = function (input, format, altConfigs) {
         if (input === null || input === '') {
             return null;
         }
-        var config = extend({
-            _i : typeof input === 'string' ? getLangDefinition().preparse(input) : input,
-            _f : format,
-            _isUTC : false
-        }, altConfigs || {});
+
+        if (typeof input === 'string') {
+            config._i = input = getLangDefinition().preparse(input);
+        }
 
         if (moment.isMoment(input)) {
             config = extend({}, input);
         }
 
         return new Moment(config);
+    }
+
+    moment = function (input, format) {
+        return makeMoment({
+            _i : input,
+            _f : format,
+            _isUTC : false
+        });
     };
 
     // creating with utc
     moment.utc = function (input, format) {
-        var config;
-
-        if (isArray(input)) {
-            config = {
-                _a : input,
-                _useUTC : true,
-                _isUTC : true
-            };
-            dateFromArray(config);
-
-            return new Moment(config);
-        }
-
-        return moment(input, format, {
-            _useUTC : true
-        }).utc();
+        return makeMoment({
+            _useUTC : true,
+            _isUTC : true,
+            _i : input,
+            _f : format
+        });
     };
 
     // creating with unix timestamp (in seconds)