2023-04-14 15:44:17 +02:00
|
|
|
From dd0dfc9cf87966f5d7493a943ec04c665be83cb6 Mon Sep 17 00:00:00 2001
|
2023-04-14 12:52:06 +02:00
|
|
|
From: Nick Cao <nickcao@nichi.co>
|
|
|
|
Date: Fri, 14 Apr 2023 09:35:25 +0800
|
|
|
|
Subject: [PATCH 4/6] qtbase: fix locating tzdir on NixOS
|
|
|
|
|
|
|
|
---
|
|
|
|
src/corelib/time/qtimezoneprivate_tz.cpp | 27 +++++++++++++++---------
|
|
|
|
1 file changed, 17 insertions(+), 10 deletions(-)
|
|
|
|
|
2022-11-04 15:57:38 +01:00
|
|
|
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
|
2023-04-14 15:44:17 +02:00
|
|
|
index 960a0944185..a5186acbd91 100644
|
2022-11-04 15:57:38 +01:00
|
|
|
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
|
|
|
|
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
|
|
|
|
@@ -51,7 +51,11 @@ 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");
|
|
|
|
+ // Try TZDIR first, in case we're running on NixOS.
|
|
|
|
+ QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
|
|
|
|
+ // Fallback to traditional paths in case we are not on NixOS.
|
|
|
|
+ if (!QFile::exists(path))
|
|
|
|
+ path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
|
|
|
|
if (!QFile::exists(path))
|
|
|
|
path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
|
|
|
|
|
2023-04-14 15:44:17 +02:00
|
|
|
@@ -730,18 +734,21 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::findEntry(const QByteArray &ianaId)
|
2022-11-04 15:57:38 +01:00
|
|
|
if (!tzif.open(QIODevice::ReadOnly))
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
- // Open named tz, try modern path first, if fails try legacy path
|
|
|
|
- tzif.setFileName("/usr/share/zoneinfo/"_L1 + QString::fromLocal8Bit(ianaId));
|
|
|
|
+ // Try TZDIR first, in case we're running on NixOS
|
|
|
|
+ tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
|
|
|
|
if (!tzif.open(QIODevice::ReadOnly)) {
|
|
|
|
- tzif.setFileName("/usr/lib/zoneinfo/"_L1 + QString::fromLocal8Bit(ianaId));
|
|
|
|
+ tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
|
|
|
|
if (!tzif.open(QIODevice::ReadOnly)) {
|
|
|
|
- // ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
|
|
|
|
- auto check = validatePosixRule(ianaId);
|
|
|
|
- if (check.isValid) {
|
|
|
|
- ret.m_hasDst = check.hasDst;
|
|
|
|
- ret.m_posixRule = ianaId;
|
|
|
|
+ tzif.setFileName("/usr/lib/zoneinfo/"_L1 + QString::fromLocal8Bit(ianaId));
|
|
|
|
+ if (!tzif.open(QIODevice::ReadOnly)) {
|
|
|
|
+ // ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
|
|
|
|
+ auto check = validatePosixRule(ianaId);
|
|
|
|
+ if (check.isValid) {
|
|
|
|
+ ret.m_hasDst = check.hasDst;
|
|
|
|
+ ret.m_posixRule = ianaId;
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
- return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-14 12:52:06 +02:00
|
|
|
--
|
|
|
|
2.39.2
|
|
|
|
|