KPublicTransport

timeutil.cpp
1 /*
2  SPDX-FileCopyrightText: 2019-2021 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "timeutil_p.h"
8 
9 #include <QDateTime>
10 #include <QTimeZone>
11 
12 using namespace KPublicTransport;
13 
14 QDateTime TimeUtil::applyTimeZone(QDateTime dt, const QTimeZone &tz)
15 {
16  if (!dt.isValid()) {
17  return dt;
18  }
19  switch (dt.timeSpec()) {
20  case Qt::LocalTime:
21  dt.setTimeZone(tz);
22  break;
23  case Qt::UTC:
24  dt = dt.toTimeZone(tz);
25  break;
26  default:
27  break;
28  }
29  return dt;
30 }
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
QDateTime toTimeZone(const QTimeZone &timeZone) const const
LocalTime
void setTimeZone(const QTimeZone &toZone)
Qt::TimeSpec timeSpec() const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:05:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.