File indexing completed on 2024-05-12 04:42:45
0001 /* 0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_MERGEUTIL_P_H 0008 #define KPUBLICTRANSPORT_MERGEUTIL_P_H 0009 0010 class QDateTime; 0011 class QString; 0012 0013 namespace KPublicTransport { 0014 0015 /** Utilities for merging objects. */ 0016 namespace MergeUtil 0017 { 0018 /** Compute the absolute difference in seconds between the two given times. 0019 * Times without timezone are assumed to be in local time *at the destination*, 0020 * not in current local timezone. This matters when comparing against a time 0021 * with a specified timezone. 0022 */ 0023 int distance(const QDateTime &lhs, const QDateTime &rhs); 0024 /** lessThan comparison of the given times, with the above timezone semantics. */ 0025 bool isBefore(const QDateTime &lhs, const QDateTime &rhs); 0026 0027 /** Assumes lhs == rhs if both sides are valid, and prefers values with timezone information. */ 0028 QDateTime mergeDateTimeEqual(const QDateTime &lhs, const QDateTime &rhs); 0029 0030 /** Takes the later time if both sides are valid, and tries to preserve timezone information. */ 0031 QDateTime mergeDateTimeMax(const QDateTime &lhs, const QDateTime &rhs); 0032 0033 /** Takes the longer input string. */ 0034 QString mergeString(const QString &lhs, const QString &rhs); 0035 } 0036 0037 } 0038 0039 #endif // KPUBLICTRANSPORT_MERGEUTIL_H