summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qtimezoneprivate_tz.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-11-30 08:28:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-11-30 09:16:58 +0100
commit87204c856ae3d8495c41af998ac196a12fe1c779 (patch)
tree5af64eaa3acde506d19fe4ab1c88b028a2197adf /src/corelib/tools/qtimezoneprivate_tz.cpp
parent498ef7f9d77fca75bcba2f657aaac38c8dc78aea (diff)
parentd0812cbdabcff4d388334c499c23992cce98d4da (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/corelib/thread/qsemaphore.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Id35b535e88df63fdfe4007ea92ed4a39c4b6d707
Diffstat (limited to 'src/corelib/tools/qtimezoneprivate_tz.cpp')
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index bcc1285472..6a5df6272a 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -1050,7 +1050,18 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
if (ianaId == "/etc/localtime")
ianaId.clear();
- // On Debian Etch and later /etc/localtime is real file with name held in /etc/timezone
+ // On most distros /etc/localtime is a symlink to a real file so extract name from the path
+ if (ianaId.isEmpty()) {
+ const QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime"));
+ if (!path.isEmpty()) {
+ // /etc/localtime is a symlink to the current TZ file, so extract from path
+ int index = path.indexOf(QLatin1String("/zoneinfo/"));
+ if (index != -1)
+ ianaId = path.mid(index + 10).toUtf8();
+ }
+ }
+
+ // On Debian Etch up to Jessie, /etc/localtime is a regular file while the actual name is in /etc/timezone
if (ianaId.isEmpty()) {
QFile tzif(QStringLiteral("/etc/timezone"));
if (tzif.open(QIODevice::ReadOnly)) {
@@ -1061,16 +1072,6 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
}
}
- // On other distros /etc/localtime is symlink to real file so can extract name from the path
- if (ianaId.isEmpty()) {
- const QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime"));
- if (!path.isEmpty()) {
- // /etc/localtime is a symlink to the current TZ file, so extract from path
- int index = path.indexOf(QLatin1String("/zoneinfo/")) + 10;
- ianaId = path.mid(index).toUtf8();
- }
- }
-
// On some Red Hat distros /etc/localtime is real file with name held in /etc/sysconfig/clock
// in a line like ZONE="Europe/Oslo" or TIMEZONE="Europe/Oslo"
if (ianaId.isEmpty()) {