1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Use a more robust check for whether a variable is a date

The simple "instanceof Date" check fails if the Date was made in a
different node.js VM
This commit is contained in:
Jeremy Ruston 2013-08-06 15:26:10 +01:00
parent 6a75a62b16
commit 4765b4a02d

View File

@ -76,6 +76,13 @@ $tw.utils.isArray = function(value) {
return Object.prototype.toString.call(value) == "[object Array]";
};
/*
Determine if a value is a date
*/
$tw.utils.isDate = function(value) {
return Object.prototype.toString.call(value) === "[object Date]";
};
/*
Iterate through all the own properties of an object or array. Callback is invoked with (element,title,object)
*/
@ -240,7 +247,7 @@ $tw.utils.parseDate = function(value) {
parseInt(value.substr(10,2)||"00",10),
parseInt(value.substr(12,2)||"00",10),
parseInt(value.substr(14,3)||"000",10)));
} else if (value instanceof Date) {
} else if ($tw.utils.isDate(value)) {
return value;
} else {
return null;