KHealthCertificate

khealthcertificate.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#include "khealthcertificate.h"
7#include "krecoverycertificate.h"
8#include "ktestcertificate.h"
9#include "kvaccinationcertificate.h"
10
11#include <QDateTime>
12#include <QVariant>
13
15{
16 if (certificate.userType() == qMetaTypeId<KVaccinationCertificate>()) {
17 const auto vac = certificate.value<KVaccinationCertificate>();
18 if (vac.certificateExpiryDate().isValid()) {
19 return vac.certificateExpiryDate();
20 }
21 return QDateTime(vac.date().addYears(1), {0, 0});
22 }
23
24 if (certificate.userType() == qMetaTypeId<KTestCertificate>()) {
25 const auto test = certificate.value<KTestCertificate>();
26 if (test.certificateExpiryDate().isValid() && test.date().isValid()) {
27 return std::min(test.certificateExpiryDate(), QDateTime(test.date().addDays(2), {0, 0}));
28 }
29 if (test.certificateExpiryDate().isValid()) {
30 return test.certificateExpiryDate();
31 }
32 return QDateTime(test.date().addDays(2), {0, 0});
33 }
34
35 if (certificate.userType() == qMetaTypeId<KRecoveryCertificate>()) {
36 const auto rec = certificate.value<KRecoveryCertificate>();
37 return QDateTime(rec.validUntil(), {0, 0});
38 }
39
40 return {};
41}
42
43#include "moc_khealthcertificate.cpp"
static QDateTime relevantUntil(const QVariant &certificate)
Returns the last date until certificate is relevant.
A recovery certificate.
A test certificate.
A vaccination certificate.
int userType() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.