From 3f962ba33604d1a8fb3829dfdb81140329e888ee Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 1 Apr 2019 22:40:05 +0800 Subject: [PATCH] Fix displaying invalid creation date The bug is only observed when using libtorrent 1.2. --- src/base/bittorrent/torrentinfo.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 17fd58f65..623bc9875 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -28,7 +28,10 @@ #include "torrentinfo.h" +#if (LIBTORRENT_VERSION_NUM < 10200) #include +#endif + #include #include @@ -164,8 +167,14 @@ QString TorrentInfo::name() const QDateTime TorrentInfo::creationDate() const { if (!isValid()) return {}; - const boost::optional t = m_nativeInfo->creation_date(); - return t ? QDateTime::fromTime_t(*t) : QDateTime(); + +#if (LIBTORRENT_VERSION_NUM < 10200) + const boost::optional date = m_nativeInfo->creation_date(); + return (date ? QDateTime::fromSecsSinceEpoch(*date) : QDateTime()); +#else + const std::time_t date = m_nativeInfo->creation_date(); + return ((date != 0) ? QDateTime::fromSecsSinceEpoch(date) : QDateTime()); +#endif } QString TorrentInfo::creator() const