linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / qt-5 / 5.12 / qtbase.patch.d / 0009-qtbase-tzdir.patch
blob03466b69afbe066c87965cc249fcd804892a7eb0
1 From db9686362ae34e02538e449e0edfe3d61065b2e9 Mon Sep 17 00:00:00 2001
2 From: Thomas Tuegel <ttuegel@mailbox.org>
3 Date: Tue, 17 Sep 2019 05:36:25 -0500
4 Subject: [PATCH 09/12] qtbase-tzdir
6 ---
7 src/corelib/tools/qtimezoneprivate_tz.cpp | 20 ++++++++++++++------
8 1 file changed, 14 insertions(+), 6 deletions(-)
10 diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
11 index 57bc000af5..d7d8119682 100644
12 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp
13 +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
14 @@ -77,7 +77,11 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
15 // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
16 static QTzTimeZoneHash loadTzTimeZones()
18 - QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
19 + // Try TZDIR first, in case we're running on NixOS.
20 + QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
21 + // Fallback to traditional paths in case we are not on NixOS.
22 + if (!QFile::exists(path))
23 + path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
24 if (!QFile::exists(path))
25 path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
27 @@ -656,12 +660,16 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
28 if (!tzif.open(QIODevice::ReadOnly))
29 return;
30 } else {
31 - // Open named tz, try modern path first, if fails try legacy path
32 - tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
33 + // Try TZDIR first, in case we're running on NixOS
34 + tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
35 if (!tzif.open(QIODevice::ReadOnly)) {
36 - tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
37 - if (!tzif.open(QIODevice::ReadOnly))
38 - return;
39 + // Open named tz, try modern path first, if fails try legacy path
40 + tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
41 + if (!tzif.open(QIODevice::ReadOnly)) {
42 + tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
43 + if (!tzif.open(QIODevice::ReadOnly))
44 + return;
45 + }
49 --
50 2.23.GIT