nixpkgs-suyu/pkgs/development/libraries/qt-5/5.4/0006-tzdir.patch

53 lines
2.2 KiB
Diff
Raw Normal View History

2015-02-21 17:54:12 +01:00
From 775fd74351faaabd45f6751618b28e2b05812d05 Mon Sep 17 00:00:00 2001
From: Thomas Tuegel <ttuegel@gmail.com>
Date: Mon, 1 Dec 2014 17:23:22 -0600
Subject: [PATCH] tzdir
---
qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
index b4ea91e..a56a245 100644
--- a/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -68,7 +68,10 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
// Parse zone.tab table, assume lists all installed zones, if not will need to read directories
static QTzTimeZoneHash loadTzTimeZones()
{
- QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+ QString path = qgetenv("TZDIR");
+ path += "/zone.tab";
+ if (!QFile::exists(path))
+ path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
if (!QFile::exists(path))
path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
@@ -559,12 +562,18 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
if (!tzif.open(QIODevice::ReadOnly))
return;
} else {
- // Open named tz, try modern path first, if fails try legacy path
- tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+ // Try TZDIR first
+ QString zoneinfoDir = qgetenv("TZDIR");
+ zoneinfoDir += "/" + QString::fromLocal8Bit(ianaId);
+ tzif.setFileName(zoneinfoDir);
if (!tzif.open(QIODevice::ReadOnly)) {
- tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
- if (!tzif.open(QIODevice::ReadOnly))
- return;
+ // Open named tz, try modern path first, if fails try legacy path
+ tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+ if (!tzif.open(QIODevice::ReadOnly)) {
+ tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+ if (!tzif.open(QIODevice::ReadOnly))
+ return;
+ }
}
}
--
2.1.3