mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
Even safer datetime parsing
This commit is contained in:
parent
ed7ae32a69
commit
72cc1eb4d4
1 changed files with 6 additions and 1 deletions
|
@ -484,7 +484,12 @@ QString misc::magnetUriToHash(QString magnet_uri) {
|
|||
|
||||
QString misc::boostTimeToQString(const boost::optional<boost::posix_time::ptime> boostDate) {
|
||||
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;
|
||||
try {
|
||||
tm = boost::posix_time::to_tm(*boostDate);
|
||||
} catch(std::exception e) {
|
||||
return tr("Unknown");
|
||||
}
|
||||
time_t t = mktime(&tm);
|
||||
if(t < 0)
|
||||
return tr("Unknown");
|
||||
|
|
Loading…
Reference in a new issue