Make sure invalid date object gets resolved

This commit is contained in:
Hadi Nategh 2017-07-17 12:49:07 +02:00
parent f4eaaf3d09
commit 8a7840660b

View File

@ -251,7 +251,7 @@ function date (format, timestamp) {
};
this.date = function (format, timestamp) {
that = this;
jsdate = ((typeof timestamp === 'undefined') ? new Date() : // Not provided
jsdate = ((typeof timestamp === 'undefined' ||isNaN(timestamp.valueOf())) ? new Date() : // Not provided
(timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
);