]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix regression re: support for mock dates. 1217/head
authorDavid J. Hamilton <davidjh@hjdivad.com>
Thu, 24 Oct 2013 23:13:42 +0000 (16:13 -0700)
committerDavid J. Hamilton <davidjh@hjdivad.com>
Thu, 24 Oct 2013 23:13:42 +0000 (16:13 -0700)
`moment(input)` needs to determine if `input` is a date.  The mechanism for
doing this was changed in ab7824f1dcca22bdb8b73f7f98cf660305a73211 to deal with
issue #1084, namely that in a node REPL `globals.Date` may not be the same
`Date` used by moment.

However, this prevents users from changing `Date`, for example by mocking it via
something like [Timecop.js](https://github.com/jamesarosen/Timecop.js).

This commit makes date checking lenient enough to handle both cases.

moment.js

index 63698b33d396f9ecda8029e682565f44d25e8f54..85fefbe4cc46b16a899fa6e421cc189b9a3fd6f1 100644 (file)
--- a/moment.js
+++ b/moment.js
     }
 
     function isDate(input) {
-        return Object.prototype.toString.call(input) === '[object Date]';
+        return  Object.prototype.toString.call(input) === '[object Date]' ||
+                input instanceof Date;
     }
 
     // compare two arrays, return the number of differences