Use QDateTime::to/fromSecsSinceEpoch()

QDateTime::to/fromTime_t() are deprecated since Qt 5.8.
This commit is contained in:
Tobias Junghans 2021-05-10 09:18:17 +02:00 committed by Albert Astals Cid
parent e6a15466ae
commit effbe387a0
4 changed files with 7 additions and 9 deletions

View File

@ -35,9 +35,7 @@ static QDateTime getTimestamp(const QString &s)
if (s.contains(QLatin1Char('T'))) { if (s.contains(QLatin1Char('T'))) {
return QDateTime::fromString(s, Qt::ISODate); return QDateTime::fromString(s, Qt::ISODate);
} else { } else {
QDateTime dt; return QDateTime::fromSecsSinceEpoch(s.toInt());
dt.setTime_t(s.toInt());
return dt;
} }
} }

View File

@ -3432,8 +3432,8 @@ public:
BN_free(bn); BN_free(bn);
// validity period // validity period
ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toTime_t()); ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toSecsSinceEpoch());
ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toTime_t()); ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toSecsSinceEpoch());
// public key // public key
X509_set_pubkey(x, pk); X509_set_pubkey(x, pk);
@ -3836,8 +3836,8 @@ public:
BN_free(bn); BN_free(bn);
// validity period // validity period
ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toTime_t()); ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toTime_t()); ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toSecsSinceEpoch());
X509_set_pubkey(x, static_cast<const MyPKeyContext *>(req.subjectPublicKey())->get_pkey()); X509_set_pubkey(x, static_cast<const MyPKeyContext *>(req.subjectPublicKey())->get_pkey());
X509_set_subject_name(x, subjectName); X509_set_subject_name(x, subjectName);

View File

@ -1048,7 +1048,7 @@ private:
Certificate cert = Certificate::fromDER(QByteArray((char *)blob, blob_size)); Certificate cert = Certificate::fromDER(QByteArray((char *)blob, blob_size));
*expiration = cert.notValidAfter().toTime_t(); *expiration = cert.notValidAfter().toSecsSinceEpoch();
return TRUE; // krazy:exclude=captruefalse return TRUE; // krazy:exclude=captruefalse
} }

View File

@ -1250,7 +1250,7 @@ public:
{ {
const QDateTime now = QDateTime::currentDateTime(); const QDateTime now = QDateTime::currentDateTime();
uint t = now.toTime_t(); uint t = now.toSecsSinceEpoch();
if (now.time().msec() > 0) if (now.time().msec() > 0)
t /= now.time().msec(); t /= now.time().msec();
qsrand(t); qsrand(t);