Commit | Line | Data |
---|---|---|
64f390a4 HG |
1 | Use $TZDIR to search for time-zone data. Thus avoid depending on package |
2 | "tzdata", which often introduces changes with near-immediate effects, so it's | |
3 | important to be able to update it fast. | |
4 | ||
5 | Based on a patch fron NixOS. | |
6 | =================================================================== | |
7 | --- qtbase-opensource-src-5.9.4.orig/src/corelib/tools/qtimezoneprivate_tz.cpp | |
8 | +++ qtbase-opensource-src-5.9.4/src/corelib/tools/qtimezoneprivate_tz.cpp | |
9 | @@ -70,7 +70,11 @@ | |
10 | // Parse zone.tab table, assume lists all installed zones, if not will need to read directories | |
11 | static QTzTimeZoneHash loadTzTimeZones() | |
12 | { | |
13 | - QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab"); | |
14 | + // Try TZDIR first, in case we're running on GuixSD. | |
15 | + QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab"); | |
16 | + // Fallback to traditional paths in case we are not on GuixSD. | |
17 | + if (!QFile::exists(path)) | |
18 | + path = QStringLiteral("/usr/share/zoneinfo/zone.tab"); | |
19 | if (!QFile::exists(path)) | |
20 | path = QStringLiteral("/usr/lib/zoneinfo/zone.tab"); | |
21 | ||
22 | @@ -645,6 +649,9 @@ | |
23 | if (!tzif.open(QIODevice::ReadOnly)) | |
24 | return; | |
25 | } else { | |
26 | + // Try TZDIR first, in case we're running on GuixSD. | |
27 | + tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId)); | |
28 | + if (!tzif.open(QIODevice::ReadOnly)) { | |
29 | // Open named tz, try modern path first, if fails try legacy path | |
30 | tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId)); | |
31 | if (!tzif.open(QIODevice::ReadOnly)) { | |
32 | @@ -652,6 +659,7 @@ | |
33 | if (!tzif.open(QIODevice::ReadOnly)) | |
34 | return; | |
35 | } | |
36 | + } | |
37 | } | |
38 | ||
39 | QDataStream ds(&tzif); |