summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qtimezoneprivate_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/time/qtimezoneprivate_p.h')
-rw-r--r--src/corelib/time/qtimezoneprivate_p.h94
1 files changed, 34 insertions, 60 deletions
diff --git a/src/corelib/time/qtimezoneprivate_p.h b/src/corelib/time/qtimezoneprivate_p.h
index 129f0343b3..0f006a7896 100644
--- a/src/corelib/time/qtimezoneprivate_p.h
+++ b/src/corelib/time/qtimezoneprivate_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Copyright (C) 2013 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// Copyright (C) 2013 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTIMEZONEPRIVATE_P_H
@@ -56,6 +20,7 @@
#include "qlist.h"
#include "qtimezone.h"
#include "private/qlocale_p.h"
+#include "private/qdatetime_p.h"
#if QT_CONFIG(icu)
#include <unicode/ucal.h>
@@ -120,7 +85,8 @@ public:
virtual bool isDaylightTime(qint64 atMSecsSinceEpoch) const;
virtual Data data(qint64 forMSecsSinceEpoch) const;
- Data dataForLocalTime(qint64 forLocalMSecs, int hint) const;
+ QDateTimePrivate::ZoneState stateAtZoneTime(qint64 forLocalMSecs,
+ QDateTimePrivate::TransitionOptions resolve) const;
virtual bool hasTransitions() const;
virtual Data nextTransition(qint64 afterMSecsSinceEpoch) const;
@@ -137,10 +103,14 @@ public:
virtual void serialize(QDataStream &ds) const;
// Static Utility Methods
- static inline qint64 maxMSecs() { return std::numeric_limits<qint64>::max(); }
- static inline qint64 minMSecs() { return std::numeric_limits<qint64>::min() + 1; }
- static inline qint64 invalidMSecs() { return std::numeric_limits<qint64>::min(); }
- static inline qint64 invalidSeconds() { return std::numeric_limits<int>::min(); }
+ [[nodiscard]] static constexpr qint64 maxMSecs()
+ { return (std::numeric_limits<qint64>::max)(); }
+ [[nodiscard]] static constexpr qint64 minMSecs()
+ { return (std::numeric_limits<qint64>::min)() + 1; }
+ [[nodiscard]] static constexpr qint64 invalidMSecs()
+ { return (std::numeric_limits<qint64>::min)(); }
+ [[nodiscard]] static constexpr qint64 invalidSeconds()
+ { return (std::numeric_limits<int>::min)(); }
static Data invalidData();
static QTimeZone::OffsetData invalidOffsetData();
static QTimeZone::OffsetData toOffsetData(const Data &data);
@@ -191,7 +161,7 @@ public:
virtual ~QUtcTimeZonePrivate();
// Fall-back for UTC[+-]\d+(:\d+){,2} IDs.
- static qint64 offsetFromUtcString(const QByteArray &id);
+ static qint64 offsetFromUtcString(QByteArrayView id);
QUtcTimeZonePrivate *clone() const override;
@@ -243,9 +213,9 @@ public:
QIcuTimeZonePrivate *clone() const override;
+ using QTimeZonePrivate::displayName;
QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType,
const QLocale &locale) const override;
- QString abbreviation(qint64 atMSecsSinceEpoch) const override;
int offsetFromUtc(qint64 atMSecsSinceEpoch) const override;
int standardTimeOffset(qint64 atMSecsSinceEpoch) const override;
@@ -262,6 +232,7 @@ public:
QByteArray systemTimeZoneId() const override;
+ bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const override;
@@ -319,9 +290,6 @@ public:
QLocale::Territory territory() const override;
QString comment() const override;
- QString displayName(qint64 atMSecsSinceEpoch,
- QTimeZone::NameType nameType,
- const QLocale &locale) const override;
QString displayName(QTimeZone::TimeType timeType,
QTimeZone::NameType nameType,
const QLocale &locale) const override;
@@ -347,20 +315,25 @@ public:
QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
private:
- void init(const QByteArray &ianaId);
+ static QByteArray staticSystemTimeZoneId();
QList<QTimeZonePrivate::Data> getPosixTransitions(qint64 msNear) const;
Data dataForTzTransition(QTzTransitionTime tran) const;
Data dataFromRule(QTzTransitionRule rule, qint64 msecsSinceEpoch) const;
#if QT_CONFIG(icu)
- mutable QSharedDataPointer<QTimeZonePrivate> m_icu;
+# ifdef __cpp_lib_is_final
+ static_assert(std::is_final<QIcuTimeZonePrivate>::value,
+ "if QIcuTimeZonePrivate isn't final, we may need to specialize "
+ "QExplicitlySharedDataPointer::clone() to call QTimeZonePrivate::clone()");
+# endif
+ mutable QExplicitlySharedDataPointer<const QIcuTimeZonePrivate> m_icu;
#endif
QTzTimeZoneCacheEntry cached_data;
- QList<QTzTransitionTime> tranCache() const { return cached_data.m_tranTimes; }
+ const QList<QTzTransitionTime> &tranCache() const { return cached_data.m_tranTimes; }
};
#endif // Q_OS_UNIX
-#ifdef Q_OS_MAC
+#ifdef Q_OS_DARWIN
class Q_AUTOTEST_EXPORT QMacTimeZonePrivate final : public QTimeZonePrivate
{
public:
@@ -393,7 +366,7 @@ public:
Data previousTransition(qint64 beforeMSecsSinceEpoch) const override;
QByteArray systemTimeZoneId() const override;
-
+ bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
NSTimeZone *nsTimeZone() const;
@@ -403,9 +376,9 @@ private:
NSTimeZone *m_nstz;
};
-#endif // Q_OS_MAC
+#endif // Q_OS_DARWIN
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !QT_CONFIG(icu)
class Q_AUTOTEST_EXPORT QWinTimeZonePrivate final : public QTimeZonePrivate
{
public:
@@ -449,10 +422,11 @@ public:
QList<QByteArray> availableTimeZoneIds() const override;
-private:
- void init(const QByteArray &ianaId);
+ // For use within implementation's TransitionTimePair:
QTimeZonePrivate::Data ruleToData(const QWinTransitionRule &rule, qint64 atMSecsSinceEpoch,
QTimeZone::TimeType type, bool fakeDst = false) const;
+private:
+ void init(const QByteArray &ianaId);
QByteArray m_windowsId;
QString m_displayName;
@@ -460,7 +434,7 @@ private:
QString m_daylightName;
QList<QWinTransitionRule> m_tranRules;
};
-#endif // Q_OS_WIN
+#endif // Q_OS_WIN && !icu
#ifdef Q_OS_ANDROID
class QAndroidTimeZonePrivate final : public QTimeZonePrivate
@@ -489,7 +463,7 @@ public:
Data data(qint64 forMSecsSinceEpoch) const override;
QByteArray systemTimeZoneId() const override;
-
+ bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
private: