KHealthCertificate

khealthcertificate.cpp
1 /*
2  * SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
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  return QDateTime(test.date().addDays(2), {0, 0});
27  }
28 
29  if (certificate.userType() == qMetaTypeId<KRecoveryCertificate>()) {
30  const auto rec = certificate.value<KRecoveryCertificate>();
31  return QDateTime(rec.validUntil(), {0, 0});
32  }
33 
34  return {};
35 }
36 
37 #include "moc_khealthcertificate.cpp"
T value() const const
static QDateTime relevantUntil(const QVariant &certificate)
Returns the last date until certificate is relevant.
int userType() const const
A test certificate.
A vaccination certificate.
A recovery certificate.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 23:19:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.