- if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
- QDateTime loginTime = QDateTime::fromTime_t(e->params()[2].toInt()).toUTC();
- displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2")
- .arg(e->params()[0], loginTime.toString("yyyy-MM-dd hh:mm:ss UTC")));
+ if (e->params().count() > 3) {
+ // if we have more then 3 params we have the above mentioned "real life" situation
+ // Time in IRC protocol is defined as seconds. Convert from seconds instead.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
+#if QT_VERSION >= 0x050800
+ QDateTime loginTime = QDateTime::fromSecsSinceEpoch(e->params()[2].toLongLong()).toUTC();
+#else
+ // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
+ QDateTime loginTime = QDateTime::fromMSecsSinceEpoch((qint64)(e->params()[2].toLongLong() * 1000)).toUTC();
+#endif
+ displayMsg(e,
+ Message::Server,
+ tr("[Whois] %1 is logged in since %2").arg(e->params()[0], loginTime.toString("yyyy-MM-dd hh:mm:ss UTC")));