diff --git a/src/misc.cpp b/src/misc.cpp index 0833caabb..3d40370eb 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -483,9 +483,15 @@ QString misc::magnetUriToHash(QString magnet_uri) { } QString misc::boostTimeToQString(const boost::optional boostDate) { - if(!boostDate) return tr("Unknown"); + if(!boostDate || !boostDate.is_initialized() || boostDate->is_not_a_date_time()) return tr("Unknown"); struct std::tm tm = boost::posix_time::to_tm(*boostDate); - return QDateTime::fromTime_t(mktime(&tm)).toString(Qt::DefaultLocaleLongDate); + time_t t = mktime(&tm); + if(t < 0) + return tr("Unknown"); + QDateTime dt = QDateTime::fromTime_t(t); + if(dt.isNull() || !dt.isValid()) + return tr("Unknown"); + return dt.toString(Qt::DefaultLocaleLongDate); } // Replace ~ in path