mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Made datetime parsing more reliable
This commit is contained in:
parent
54b53f3aba
commit
ed7ae32a69
10
src/misc.cpp
10
src/misc.cpp
@ -483,9 +483,15 @@ QString misc::magnetUriToHash(QString magnet_uri) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString misc::boostTimeToQString(const boost::optional<boost::posix_time::ptime> boostDate) {
|
QString misc::boostTimeToQString(const boost::optional<boost::posix_time::ptime> 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);
|
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
|
// Replace ~ in path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user