From effbe387a099b04909b0d20f5ae017e21e060e6d Mon Sep 17 00:00:00 2001 From: Tobias Junghans <tobydox@veyon.io> Date: Mon, 10 May 2021 09:18:17 +0200 Subject: [PATCH] Use QDateTime::to/fromSecsSinceEpoch() QDateTime::to/fromTime_t() are deprecated since Qt 5.8. --- plugins/qca-gnupg/gpgaction.cpp | 4 +--- plugins/qca-ossl/qca-ossl.cpp | 8 ++++---- plugins/qca-pkcs11/qca-pkcs11.cpp | 2 +- src/qca_default.cpp | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/qca-gnupg/gpgaction.cpp b/plugins/qca-gnupg/gpgaction.cpp index 18ef52af..c739dd1a 100644 --- a/plugins/qca-gnupg/gpgaction.cpp +++ b/plugins/qca-gnupg/gpgaction.cpp @@ -35,9 +35,7 @@ static QDateTime getTimestamp(const QString &s) if (s.contains(QLatin1Char('T'))) { return QDateTime::fromString(s, Qt::ISODate); } else { - QDateTime dt; - dt.setTime_t(s.toInt()); - return dt; + return QDateTime::fromSecsSinceEpoch(s.toInt()); } } diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp index ac3f4b24..036de356 100644 --- a/plugins/qca-ossl/qca-ossl.cpp +++ b/plugins/qca-ossl/qca-ossl.cpp @@ -3432,8 +3432,8 @@ public: BN_free(bn); // validity period - ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toTime_t()); - ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toTime_t()); + ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toSecsSinceEpoch()); + ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toSecsSinceEpoch()); // public key X509_set_pubkey(x, pk); @@ -3836,8 +3836,8 @@ public: BN_free(bn); // validity period - ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toTime_t()); - ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toTime_t()); + ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toSecsSinceEpoch()); + ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toSecsSinceEpoch()); X509_set_pubkey(x, static_cast<const MyPKeyContext *>(req.subjectPublicKey())->get_pkey()); X509_set_subject_name(x, subjectName); diff --git a/plugins/qca-pkcs11/qca-pkcs11.cpp b/plugins/qca-pkcs11/qca-pkcs11.cpp index 2585839b..ae13bf0a 100644 --- a/plugins/qca-pkcs11/qca-pkcs11.cpp +++ b/plugins/qca-pkcs11/qca-pkcs11.cpp @@ -1048,7 +1048,7 @@ private: Certificate cert = Certificate::fromDER(QByteArray((char *)blob, blob_size)); - *expiration = cert.notValidAfter().toTime_t(); + *expiration = cert.notValidAfter().toSecsSinceEpoch(); return TRUE; // krazy:exclude=captruefalse } diff --git a/src/qca_default.cpp b/src/qca_default.cpp index a06bb592..977ced99 100644 --- a/src/qca_default.cpp +++ b/src/qca_default.cpp @@ -1250,7 +1250,7 @@ public: { const QDateTime now = QDateTime::currentDateTime(); - uint t = now.toTime_t(); + uint t = now.toSecsSinceEpoch(); if (now.time().msec() > 0) t /= now.time().msec(); qsrand(t);