From: Isaac Cambron Date: Sun, 15 Sep 2013 08:06:30 +0000 (-0400) Subject: be smarter about deciding whether something is a date or not. fixes #1084 X-Git-Tag: 2.3.0~36^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1091%2Fhead;p=thirdparty%2Fmoment.git be smarter about deciding whether something is a date or not. fixes #1084 --- diff --git a/moment.js b/moment.js index 3a5ebd2fe..4cd32db69 100644 --- a/moment.js +++ b/moment.js @@ -347,6 +347,10 @@ return Object.prototype.toString.call(input) === '[object Array]'; } + function isDate(input) { + return Object.prototype.toString.call(input) === '[object Date]'; + } + // compare two arrays, return the number of differences function compareArrays(array1, array2) { var len = Math.min(array1.length, array2.length), @@ -985,7 +989,7 @@ } else if (isArray(input)) { config._a = input.slice(0); dateFromArray(config); - } else if (input instanceof Date) { + } else if (isDate(input)) { config._d = new Date(+input); } else if (typeof(input) === 'object') { dateFromObject(config);