Add support for /etc/TZ as default value for $TZ
This is used by uClibc, at least. [ChangeLog][QtCore][QTimeZone] The TZDB back-end now recognizes the contents of /etc/TZ as a fall-back for $TZ (as used by uClibc). Fixes: QTBUG-75565 Change-Id: I3067e2d023cf30a85633575b5d7dc0ee3ec36927 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ab2655c559
commit
0fb30652b5
@ -659,7 +659,7 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
|
|||||||
if (!tzif.open(QIODevice::ReadOnly)) {
|
if (!tzif.open(QIODevice::ReadOnly)) {
|
||||||
tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
|
tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
|
||||||
if (!tzif.open(QIODevice::ReadOnly)) {
|
if (!tzif.open(QIODevice::ReadOnly)) {
|
||||||
// ianaId may be a POSIX rule, taken from $TZ
|
// ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
|
||||||
const QByteArray zoneInfo = ianaId.split(',').at(0);
|
const QByteArray zoneInfo = ianaId.split(',').at(0);
|
||||||
const char *begin = zoneInfo.constBegin();
|
const char *begin = zoneInfo.constBegin();
|
||||||
if (PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset()
|
if (PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset()
|
||||||
@ -1114,6 +1114,13 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some systems (e.g. uClibc) have a default value for $TZ in /etc/TZ:
|
||||||
|
if (ianaId.isEmpty()) {
|
||||||
|
QFile zone(QStringLiteral("/etc/TZ"));
|
||||||
|
if (zone.open(QIODevice::ReadOnly))
|
||||||
|
ianaId = zone.readAll().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
// Give up for now and return UTC
|
// Give up for now and return UTC
|
||||||
if (ianaId.isEmpty())
|
if (ianaId.isEmpty())
|
||||||
ianaId = utcQByteArray();
|
ianaId = utcQByteArray();
|
||||||
|
Loading…
Reference in New Issue
Block a user