From ab7824f1dcca22bdb8b73f7f98cf660305a73211 Mon Sep 17 00:00:00 2001 From: Isaac Cambron Date: Sun, 15 Sep 2013 04:06:30 -0400 Subject: [PATCH] be smarter about deciding whether something is a date or not. fixes #1084 --- moment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.47.2