From 54f768896f40451855ac6210cda4adda488276dd Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Tue, 9 Feb 2021 09:12:34 +0100 Subject: [PATCH] update to be compatible with Qt 6 --- README | 8 +++----- include/tzdata.h | 4 ++-- src/tzdata.cpp | 9 +++++---- src/tzfile.cpp | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README b/README index 608fde7..95ff44f 100644 --- a/README +++ b/README @@ -11,10 +11,12 @@ It transforms unix timestamps, its own format and QDateTime objects. Other than the original tzcode package it can be compiled out of the box with Qt for Windows and integrates well with Qt. +It is compatible with Qt 5.8 or newer and Qt 6. + Copyright ---------- -(c) Konrad Rosenbaum, 2010-2015 +(c) Konrad Rosenbaum, 2010-2021 protected under the GNU GPL v3 or at your option any newer see COPYING for details @@ -30,10 +32,6 @@ These files are in the public domain. See db/README. Big Fat Warning ------------------ -So far this software is beta. This means it might calculate the wrong time, -corrupt your data, eat your disk, misplace next weeks appointments, etc. -ad infinitum, ad nauseam, ... - This software comes with no warranty at all. You use it at your own risk. diff --git a/include/tzdata.h b/include/tzdata.h index 6456c5e..3d332e7 100644 --- a/include/tzdata.h +++ b/include/tzdata.h @@ -276,10 +276,10 @@ class TZLIB_EXPORT TimeStamp /**returns the current date/time as localized time stamps \param zone the name of the target time zone*/ - static TimeStamp now(QString zone){return TimeStamp(QDateTime::currentDateTime().toTime_t(),zone);} + static TimeStamp now(QString zone){return TimeStamp(QDateTime::currentDateTime().toSecsSinceEpoch(),zone);} /**returns the current date/time as time stamp \param isLocal if true the timestamp will be in the default time zone, if false on UTC*/ - static TimeStamp now(bool isLocal=true){return TimeStamp(QDateTime::currentDateTime().toTime_t(),isLocal);} + static TimeStamp now(bool isLocal=true){return TimeStamp(QDateTime::currentDateTime().toSecsSinceEpoch(),isLocal);} /**sets the global search repository for time zones, this only affects time zones that have not been loaded yet*/ static void setSearchPath(const QStringList&); diff --git a/src/tzdata.cpp b/src/tzdata.cpp index 076ed52..394cd71 100644 --- a/src/tzdata.cpp +++ b/src/tzdata.cpp @@ -11,6 +11,7 @@ // #include +#include static inline void initResource(){Q_INIT_RESOURCE(zonefiles);} #include "tzdata.h" @@ -27,7 +28,7 @@ using namespace TimeZoneLib; static QMapregistry; -static QRegExp zoneRegExp=QRegExp("[a-zA-Z0-9/_-]+"); +static QRegularExpression zoneRegExp=QRegularExpression("^[a-zA-Z0-9/_-]+$"); static QString defaultzone; @@ -47,7 +48,7 @@ TZFile& TimeZoneLib::getRegistryZone(QString zn) if(registry.contains(zn)) return registry[zn]; //syntax check - if(!zoneRegExp.exactMatch(zn)) + if(!zoneRegExp.match(zn).hasMatch()) return registry["UTC"]; //load it TZFile tf(zn); @@ -151,7 +152,7 @@ TimeStamp::TimeStamp ( const QTime&tm , QString z) TimeStamp::TimeStamp ( const QDateTime&d ) { initDefault(); - m_unix=d.toTime_t();m_msec=d.time().msec(); + m_unix=d.toSecsSinceEpoch();m_msec=d.time().msec(); if(d.timeSpec()!=Qt::UTC) setZone(defaultzone); else @@ -371,7 +372,7 @@ bool TimeStamp::setDefaultZone(QString z) return true; } //syntax check - if(!zoneRegExp.exactMatch(z)){ + if(!zoneRegExp.match(z).hasMatch()){ defaultzone="UTC"; return false; } diff --git a/src/tzfile.cpp b/src/tzfile.cpp index 5a51643..debc7bb 100644 --- a/src/tzfile.cpp +++ b/src/tzfile.cpp @@ -360,7 +360,7 @@ QString TZFile::version()const //can only determine it if it is an internal or real file if(m_fname.isEmpty())return QString(); //split out dir name - QStringList ls=m_fname.split("/",QString::SkipEmptyParts); + QStringList ls=m_fname.split("/",Qt::SkipEmptyParts); if(ls.size()<3)return QString(); //reduce to zoneinfo dir for(int i=0;i