Work around macOS's inconsistency in naming of India's time-zone
macOS fails to create a zone for the name its own systemTimeZone claims to have (see new comment). So make sure we do consistently recognize the name systemTimeZoneId() returns, using systemTimeZone from which we got its name. Add minimal testing of system time-zone. Fixes: QTBUG-80173 Change-Id: I42f21efbd7c439158fee954d555414bb180e7f8f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
2a4dd69499
commit
cfd2f3c46e
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
|
** Copyright (C) 2019 The Qt Company Ltd.
|
||||||
** Copyright (C) 2013 John Layt <jlayt@kde.org>
|
** Copyright (C) 2013 John Layt <jlayt@kde.org>
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
@ -94,6 +95,16 @@ void QMacTimeZonePrivate::init(const QByteArray &ianaId)
|
|||||||
if (m_nstz)
|
if (m_nstz)
|
||||||
m_id = ianaId;
|
m_id = ianaId;
|
||||||
}
|
}
|
||||||
|
if (!m_nstz) {
|
||||||
|
// macOS has been seen returning a systemTimeZone which reports its name
|
||||||
|
// as Asia/Kolkata, which doesn't appear in knownTimeZoneNames (which
|
||||||
|
// calls the zone Asia/Calcutta). So explicitly check for the name
|
||||||
|
// systemTimeZoneId() returns, and use systemTimeZone if we get it:
|
||||||
|
m_nstz = [NSTimeZone.systemTimeZone retain];
|
||||||
|
Q_ASSERT(m_nstz);
|
||||||
|
if (QString::fromNSString(m_nstz.name).toUtf8() == ianaId)
|
||||||
|
m_id = ianaId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QMacTimeZonePrivate::comment() const
|
QString QMacTimeZonePrivate::comment() const
|
||||||
|
@ -46,6 +46,7 @@ private slots:
|
|||||||
// Public class default system tests
|
// Public class default system tests
|
||||||
void createTest();
|
void createTest();
|
||||||
void nullTest();
|
void nullTest();
|
||||||
|
void systemZone();
|
||||||
void dataStreamTest();
|
void dataStreamTest();
|
||||||
void isTimeZoneIdAvailable();
|
void isTimeZoneIdAvailable();
|
||||||
void availableTimeZoneIds();
|
void availableTimeZoneIds();
|
||||||
@ -315,6 +316,14 @@ void tst_QTimeZone::nullTest()
|
|||||||
QCOMPARE(data.daylightTimeOffset, std::numeric_limits<int>::min());
|
QCOMPARE(data.daylightTimeOffset, std::numeric_limits<int>::min());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTimeZone::systemZone()
|
||||||
|
{
|
||||||
|
const QTimeZone zone = QTimeZone::systemTimeZone();
|
||||||
|
QVERIFY(zone.isValid());
|
||||||
|
QCOMPARE(zone.id(), QTimeZone::systemTimeZoneId());
|
||||||
|
QCOMPARE(zone, QTimeZone(QTimeZone::systemTimeZoneId()));
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTimeZone::dataStreamTest()
|
void tst_QTimeZone::dataStreamTest()
|
||||||
{
|
{
|
||||||
// Test the OffsetFromUtc backend serialization. First with a custom timezone:
|
// Test the OffsetFromUtc backend serialization. First with a custom timezone:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user