OSDN Git Service

use tm::tm_zone member for timezone if available
authorIvailo Monev <xakepa10@gmail.com>
Tue, 7 Sep 2021 02:15:08 +0000 (05:15 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 7 Sep 2021 02:15:08 +0000 (05:15 +0300)
for reference:
https://www.openwall.com/lists/musl/2021/04/25/1
https://github.com/openbsd/src/blob/2207c4325726fdc5c4bcd0011af0fdf7d3dab137/lib/libc/time/Theory#L167

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/qcorecommon_p.h

index 4fb0544..85c1927 100644 (file)
@@ -56,7 +56,12 @@ static inline QString timeZone()
 #else
     struct tm *t = ::localtime(&ltime);
 #endif // !QT_NO_THREAD
+
+#if defined(QT_HAVE_TM_TM_ZONE)
+    return QString::fromLocal8Bit(t->tm_zone);
+#else
     return QString::fromLocal8Bit(tzname[t->tm_isdst]);
+#endif
 }
 
 // Returns a human readable representation of the first \a len