Commit 4c5e5b94 authored by Damien Caliste's avatar Damien Caliste

[qtbase] Detect system time zone from linked symlinks.

parent a002c4eb
......@@ -1013,11 +1013,18 @@ 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()) {
QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime"));
int index;
int iteration = 0;
// Symlink may point to another symlink etc. before being under zoneinfo/
while (iteration < 5 && !path.isEmpty()
&& (index = path.indexOf(QLatin1String("/zoneinfo/"))) < 0) {
path = QFile::symLinkTarget(path);
iteration += 1;
}
if (!path.isEmpty() && index >= 0) {
// /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();
ianaId = path.mid(index + 10).toUtf8();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment