diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-02-06 12:20:50 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2023-02-14 18:27:09 +0100 |
commit | ff7d5809f1c8b27d62201c77fd1ea556a4fe3cc8 (patch) | |
tree | 231d27a836e7ac1667d305920dba3855e9c79ddc | |
parent | bf6cc9a4e2825ecc1b64955dd6341a8ec758dacc (diff) |
Route QTimeZone::setSecondsAheadOfUtc() via setDurationAheadOfUtc()
... rather than the other way round. This ensures that the latter's
check for value-in-range is correctly handled.
Pick-to: 6.5
Task-number: QTBUG-109580
Change-Id: I21c2e7c1787c8f57e6893353e42261c013b648f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r-- | src/corelib/time/qtimezone.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/time/qtimezone.h b/src/corelib/time/qtimezone.h index 20b6df2ad5..273bcc7b1c 100644 --- a/src/corelib/time/qtimezone.h +++ b/src/corelib/time/qtimezone.h @@ -121,13 +121,14 @@ public: static QTimeZone fromDurationAheadOfUtc(std::chrono::seconds offset) { - return fromSecondsAheadOfUtc(int(offset.count())); + return QTimeZone((offset.count() >= MinUtcOffsetSecs && offset.count() <= MaxUtcOffsetSecs) + ? ShortData(offset.count() ? Qt::OffsetFromUTC : Qt::UTC, + int(offset.count())) + : ShortData(Qt::TimeZone)); } static QTimeZone fromSecondsAheadOfUtc(int offset) { - return QTimeZone((offset >= MinUtcOffsetSecs && offset <= MaxUtcOffsetSecs) - ? ShortData(offset ? Qt::OffsetFromUTC : Qt::UTC, offset) - : ShortData(Qt::TimeZone)); + return fromDurationAheadOfUtc(std::chrono::seconds{offset});; } constexpr Qt::TimeSpec timeSpec() const noexcept { return d.s.spec(); } constexpr int fixedSecondsAheadOfUtc() const noexcept |