mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -06:00
Even safer dateTime parsing
This commit is contained in:
@@ -424,7 +424,12 @@ 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 || !boostDate.is_initialized() || boostDate->is_not_a_date_time()) 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;
|
||||||
|
try {
|
||||||
|
tm = boost::posix_time::to_tm(*boostDate);
|
||||||
|
} catch(std::exception e) {
|
||||||
|
return tr("Unknown");
|
||||||
|
}
|
||||||
time_t t = mktime(&tm);
|
time_t t = mktime(&tm);
|
||||||
if(t < 0)
|
if(t < 0)
|
||||||
return tr("Unknown");
|
return tr("Unknown");
|
||||||
|
|||||||
Reference in New Issue
Block a user