diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-08-28 15:32:09 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-28 15:48:17 +0200 |
commit | b12d6c6a8ab5f7b01bdd2cb862a66a409700faa1 (patch) | |
tree | 96e4ad9c549c3c350465c6f706e52a816c4e48ed /src/corelib/time/qtimezoneprivate_win.cpp | |
parent | 32309fb4462aaf86c6efe9a99a8d41d7d2b24bfd (diff) |
Don't guess UTC when we can't find a system zone name
If we're able to load a system zone without knowing its name, we
shouldn't claim that its name is UTC. Instead, use the system zone
information's name for the zone.
Let the backend return an empty string if it can't determine the
system zone ID, provided it has some way to get system zone info
despite not knowing its name. This can happen on Windows if the system
zone is one of Microsoft's idiosyncratic names that we don't
recognize; or on Linux if /etc/timezone is a copy of a zoneinfo file,
instead of a symlink. In support of that, handle empty ID as a request
for system zone info, so that the backend constructors taking an IANA
ID never get passed an empty ID; that gets routed to the default
constructor instead.
This incidentally restores QTzTimeZonePrivate's behavior, for empty
ID, of reading the content of /etc/timezone if we are unable to
determine the name of its zone any other way.
Fixes: QTBUG-86306
Pick-to: 5.15 5.15.1
Change-Id: Iad57c18199124f651ebc3d32c3deffca6eaab512
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/time/qtimezoneprivate_win.cpp')
-rw-r--r-- | src/corelib/time/qtimezoneprivate_win.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp index 1dc362e45a..7c80dbc38b 100644 --- a/src/corelib/time/qtimezoneprivate_win.cpp +++ b/src/corelib/time/qtimezoneprivate_win.cpp @@ -510,6 +510,8 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId) m_id.clear(); m_windowsId.clear(); m_displayName.clear(); + } else if (m_id.isEmpty()) { + m_id = m_standardName.toUtf8(); } } @@ -732,12 +734,8 @@ QByteArray QWinTimeZonePrivate::systemTimeZoneId() const if (country != QLocale::AnyCountry) ianaId = windowsIdToDefaultIanaId(windowsId, country); // If we don't have a real country, or there wasn't a specific match, try the global default - if (ianaId.isEmpty()) { + if (ianaId.isEmpty()) ianaId = windowsIdToDefaultIanaId(windowsId); - // If no global default then probably an unknown Windows ID so return UTC - if (ianaId.isEmpty()) - return utcQByteArray(); - } return ianaId; } |