Skip to content

Commit 2979eb9

Browse files
authored
Hopefully fix TimeSpec deprecation (#4)
* Update CMake to 3.15 and make libcommuni actually find Qt * Hopefully fix `warning: ‘QDateTime QDateTime::toTimeSpec(Qt::TimeSpec) const’ is deprecated: Use toTimeZone instead [-Wdeprecated-declarations]` * Add QT_VERSION_CHECKs (tested by compiling using 6.8.1)
1 parent 3ce9161 commit 2979eb9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.15)
22

3-
project(LibCommuni VERSION 3.6.0)
3+
project(LibCommuni VERSION 3.7.0)
44

55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -9,6 +9,14 @@ set(CMAKE_AUTOMOC ON)
99
set(CMAKE_AUTORCC ON)
1010
set(CMAKE_AUTOUIC ON)
1111

12+
option(BUILD_WITH_QT6 "Build with Qt6" On)
13+
14+
if (BUILD_WITH_QT6)
15+
set(MAJOR_QT_VERSION "6")
16+
else()
17+
set(MAJOR_QT_VERSION "5")
18+
endif()
19+
1220
find_package(Qt${MAJOR_QT_VERSION} REQUIRED COMPONENTS Core Network)
1321

1422
if (BUILD_WITH_QT6)

src/core/ircmessage.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include <QMetaEnum>
3939
#include <QVariant>
4040
#include <QDebug>
41+
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 9)
42+
#include <QTimeZone>
43+
#endif
4144
#include <functional>
4245

4346
IRC_BEGIN_NAMESPACE
@@ -701,7 +704,11 @@ IrcMessage* IrcMessage::fromData(const QByteArray& data, IrcConnection* connecti
701704
if (!tag.isEmpty()) {
702705
QDateTime ts = QDateTime::fromString(QString::fromUtf8(tag), Qt::ISODate);
703706
if (ts.isValid())
707+
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 9)
708+
message->d_ptr->timeStamp = ts.toTimeZone(QTimeZone::LocalTime);
709+
#else
704710
message->d_ptr->timeStamp = ts.toTimeSpec(Qt::LocalTime);
711+
#endif
705712
}
706713
return message;
707714
}

0 commit comments

Comments
 (0)