kopia lustrzana https://github.com/miklobit/TiddlyWiki5
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 VMprint-window-tiddler
rodzic
6a75a62b16
commit
4765b4a02d
|
@ -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;
|
||||
|
|
Ładowanie…
Reference in New Issue