Make qtbase compile without QT_CONFIG(timezone)
Fixes: QTBUG-83795 Pick-to: 5.15 Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
255cc55d74
commit
b428e98052
@ -55,7 +55,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSDate);
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
class QTimeZone;
|
class QTimeZone;
|
||||||
|
#endif
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
|
|
||||||
class Q_CORE_EXPORT QDate // ### Qt 6: change to be used by value, not const &
|
class Q_CORE_EXPORT QDate // ### Qt 6: change to be used by value, not const &
|
||||||
|
@ -788,11 +788,9 @@ QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex,
|
|||||||
text->replace(offset, used, sectiontext.constData(), used);
|
text->replace(offset, used, sectiontext.constData(), used);
|
||||||
break; }
|
break; }
|
||||||
case TimeZoneSection:
|
case TimeZoneSection:
|
||||||
#if QT_CONFIG(timezone)
|
|
||||||
result = findTimeZone(sectionTextRef, currentValue,
|
result = findTimeZone(sectionTextRef, currentValue,
|
||||||
absoluteMax(sectionIndex),
|
absoluteMax(sectionIndex),
|
||||||
absoluteMin(sectionIndex));
|
absoluteMin(sectionIndex));
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case MonthSection:
|
case MonthSection:
|
||||||
case DayOfWeekSectionShort:
|
case DayOfWeekSectionShort:
|
||||||
@ -1692,7 +1690,12 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
|
|||||||
if (index > 0 && maxVal >= offset && offset >= minVal)
|
if (index > 0 && maxVal >= offset && offset >= minVal)
|
||||||
return ParsedSection(Acceptable, offset, index);
|
return ParsedSection(Acceptable, offset, index);
|
||||||
|
|
||||||
#endif // timezone
|
#else // timezone
|
||||||
|
Q_UNUSED(str);
|
||||||
|
Q_UNUSED(when);
|
||||||
|
Q_UNUSED(maxVal);
|
||||||
|
Q_UNUSED(minVal);
|
||||||
|
#endif
|
||||||
return ParsedSection();
|
return ParsedSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1728,9 +1728,12 @@ QDateTime QDateTimeEditPrivate::convertTimeSpec(const QDateTime &datetime)
|
|||||||
return datetime.toLocalTime();
|
return datetime.toLocalTime();
|
||||||
case Qt::OffsetFromUTC:
|
case Qt::OffsetFromUTC:
|
||||||
return datetime.toOffsetFromUtc(value.toDateTime().offsetFromUtc());
|
return datetime.toOffsetFromUtc(value.toDateTime().offsetFromUtc());
|
||||||
#if QT_CONFIG(timezone)
|
|
||||||
case Qt::TimeZone:
|
case Qt::TimeZone:
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
return datetime.toTimeZone(value.toDateTime().timeZone());
|
return datetime.toTimeZone(value.toDateTime().timeZone());
|
||||||
|
#else
|
||||||
|
qWarning("QDateTimeEdit: Internal: enable timezone feature to support Qt::TimeZone");
|
||||||
|
return datetime;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
|
@ -1787,6 +1787,7 @@ void tst_QLocale::formatTimeZone()
|
|||||||
const QString cest(QStringLiteral("CEST"));
|
const QString cest(QStringLiteral("CEST"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QDateTime dt6(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin"));
|
QDateTime dt6(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
|
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
|
||||||
@ -1798,6 +1799,7 @@ void tst_QLocale::formatTimeZone()
|
|||||||
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
|
QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue);
|
||||||
#endif
|
#endif
|
||||||
QCOMPARE(enUS.toString(dt7, "t"), cest);
|
QCOMPARE(enUS.toString(dt7, "t"), cest);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Current datetime should return current abbreviation
|
// Current datetime should return current abbreviation
|
||||||
QCOMPARE(enUS.toString(QDateTime::currentDateTime(), "t"),
|
QCOMPARE(enUS.toString(QDateTime::currentDateTime(), "t"),
|
||||||
|
@ -709,9 +709,11 @@ void tst_QDateTime::setMSecsSinceEpoch()
|
|||||||
QCOMPARE(localDt.timeSpec(), Qt::LocalTime);
|
QCOMPARE(localDt.timeSpec(), Qt::LocalTime);
|
||||||
|
|
||||||
// Compare result for LocalTime to TimeZone
|
// Compare result for LocalTime to TimeZone
|
||||||
QTimeZone europe("Europe/Oslo");
|
|
||||||
QDateTime dt2;
|
QDateTime dt2;
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
|
QTimeZone europe("Europe/Oslo");
|
||||||
dt2.setTimeZone(europe);
|
dt2.setTimeZone(europe);
|
||||||
|
#endif
|
||||||
dt2.setMSecsSinceEpoch(msecs);
|
dt2.setMSecsSinceEpoch(msecs);
|
||||||
QCOMPARE(dt2.date(), cet.date());
|
QCOMPARE(dt2.date(), cet.date());
|
||||||
|
|
||||||
@ -720,8 +722,10 @@ void tst_QDateTime::setMSecsSinceEpoch()
|
|||||||
// have hard limits. Let's restrict it to the 32-bit Unix range
|
// have hard limits. Let's restrict it to the 32-bit Unix range
|
||||||
if (dt2.date().year() >= 1970 && dt2.date().year() <= 2037)
|
if (dt2.date().year() >= 1970 && dt2.date().year() <= 2037)
|
||||||
QCOMPARE(dt2.time(), cet.time());
|
QCOMPARE(dt2.time(), cet.time());
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QCOMPARE(dt2.timeSpec(), Qt::TimeZone);
|
QCOMPARE(dt2.timeSpec(), Qt::TimeZone);
|
||||||
QCOMPARE(dt2.timeZone(), europe);
|
QCOMPARE(dt2.timeZone(), europe);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(dt.toMSecsSinceEpoch(), msecs);
|
QCOMPARE(dt.toMSecsSinceEpoch(), msecs);
|
||||||
@ -958,14 +962,15 @@ void tst_QDateTime::toString_textDate_extra()
|
|||||||
QVERIFY(!dt.toString().endsWith(GMT));
|
QVERIFY(!dt.toString().endsWith(GMT));
|
||||||
dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC).toLocalTime();
|
dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC).toLocalTime();
|
||||||
QVERIFY(!dt.toString().endsWith(GMT));
|
QVERIFY(!dt.toString().endsWith(GMT));
|
||||||
if (QTimeZone::systemTimeZone().offsetFromUtc(dt))
|
|
||||||
QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970"));
|
|
||||||
else
|
|
||||||
QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970"));
|
|
||||||
#if QT_CONFIG(timezone)
|
#if QT_CONFIG(timezone)
|
||||||
# if defined Q_OS_UNIX && !defined Q_OS_DARWIN && !defined Q_OS_ANDROID
|
# if defined Q_OS_UNIX && !defined Q_OS_DARWIN && !defined Q_OS_ANDROID
|
||||||
# define CORRECT_ZONE_ABBREV
|
# define CORRECT_ZONE_ABBREV
|
||||||
# endif // QTBUG-57320, QTBUG-57298, QTBUG-68833
|
# endif // QTBUG-57320, QTBUG-57298, QTBUG-68833
|
||||||
|
if (QTimeZone::systemTimeZone().offsetFromUtc(dt))
|
||||||
|
QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970"));
|
||||||
|
else
|
||||||
|
QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970"));
|
||||||
|
|
||||||
QTimeZone PST("America/Vancouver");
|
QTimeZone PST("America/Vancouver");
|
||||||
if (PST.isValid()) {
|
if (PST.isValid()) {
|
||||||
@ -993,7 +998,12 @@ void tst_QDateTime::toString_textDate_extra()
|
|||||||
} else {
|
} else {
|
||||||
qDebug("Missed zone test: no Europe/Berlin zone available");
|
qDebug("Missed zone test: no Europe/Berlin zone available");
|
||||||
}
|
}
|
||||||
#endif // timezone
|
#else // timezone
|
||||||
|
if (dt.offsetFromUtc())
|
||||||
|
QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970"));
|
||||||
|
else
|
||||||
|
QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970"));
|
||||||
|
#endif
|
||||||
dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC);
|
dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC);
|
||||||
QVERIFY(dt.toString().endsWith(GMT));
|
QVERIFY(dt.toString().endsWith(GMT));
|
||||||
}
|
}
|
||||||
@ -2501,10 +2511,11 @@ void tst_QDateTime::fromStringStringFormat_data()
|
|||||||
QTest::newRow("data13") << QString("30.02.2004") << QString("dd.MM.yyyy") << invalidDateTime();
|
QTest::newRow("data13") << QString("30.02.2004") << QString("dd.MM.yyyy") << invalidDateTime();
|
||||||
QTest::newRow("data14") << QString("32.01.2004") << QString("dd.MM.yyyy") << invalidDateTime();
|
QTest::newRow("data14") << QString("32.01.2004") << QString("dd.MM.yyyy") << invalidDateTime();
|
||||||
QTest::newRow("data15") << QString("Thu January 2004") << QString("ddd MMMM yyyy") << QDateTime(QDate(2004, 1, 1), QTime());
|
QTest::newRow("data15") << QString("Thu January 2004") << QString("ddd MMMM yyyy") << QDateTime(QDate(2004, 1, 1), QTime());
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
|
// Qt::UTC and Qt::OffsetFromUTC not supported without timezone: QTBUG-83844
|
||||||
QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z")
|
QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z")
|
||||||
<< QString("yyyy-MM-ddThh:mm:ss.zt")
|
<< QString("yyyy-MM-ddThh:mm:ss.zt")
|
||||||
<< QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1), Qt::UTC);
|
<< QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1), Qt::UTC);
|
||||||
#if QT_CONFIG(timezone)
|
|
||||||
QTimeZone southBrazil("America/Sao_Paulo");
|
QTimeZone southBrazil("America/Sao_Paulo");
|
||||||
if (southBrazil.isValid()) {
|
if (southBrazil.isValid()) {
|
||||||
QTest::newRow("spring-forward-midnight")
|
QTest::newRow("spring-forward-midnight")
|
||||||
@ -2541,8 +2552,10 @@ void tst_QDateTime::fromStringStringFormat()
|
|||||||
|
|
||||||
if (expected.isValid()) {
|
if (expected.isValid()) {
|
||||||
QCOMPARE(dt.timeSpec(), expected.timeSpec());
|
QCOMPARE(dt.timeSpec(), expected.timeSpec());
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
if (expected.timeSpec() == Qt::TimeZone)
|
if (expected.timeSpec() == Qt::TimeZone)
|
||||||
QCOMPARE(dt.timeZone(), expected.timeZone());
|
QCOMPARE(dt.timeZone(), expected.timeZone());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
QCOMPARE(dt, expected);
|
QCOMPARE(dt, expected);
|
||||||
}
|
}
|
||||||
@ -2589,7 +2602,15 @@ void tst_QDateTime::fromStringToStringLocale()
|
|||||||
ROUNDTRIP(Qt::SystemLocaleDate);
|
ROUNDTRIP(Qt::SystemLocaleDate);
|
||||||
ROUNDTRIP(Qt::LocaleDate);
|
ROUNDTRIP(Qt::LocaleDate);
|
||||||
|
|
||||||
|
#if !QT_CONFIG(timezone)
|
||||||
|
QEXPECT_FAIL("", "Long date formats (with time-zone specifiers) need timezone feature enabled",
|
||||||
|
Continue);
|
||||||
|
#endif
|
||||||
ROUNDTRIP(Qt::DefaultLocaleLongDate);
|
ROUNDTRIP(Qt::DefaultLocaleLongDate);
|
||||||
|
#if !QT_CONFIG(timezone)
|
||||||
|
QEXPECT_FAIL("", "Long date formats (with time-zone specifiers) need timezone feature enabled",
|
||||||
|
Continue);
|
||||||
|
#endif
|
||||||
ROUNDTRIP(Qt::SystemLocaleLongDate);
|
ROUNDTRIP(Qt::SystemLocaleLongDate);
|
||||||
#undef ROUNDTRIP
|
#undef ROUNDTRIP
|
||||||
QLocale::setDefault(def);
|
QLocale::setDefault(def);
|
||||||
@ -2605,7 +2626,9 @@ void tst_QDateTime::offsetFromUtc()
|
|||||||
// Offset constructor
|
// Offset constructor
|
||||||
QDateTime dt1(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, 60 * 60);
|
QDateTime dt1(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, 60 * 60);
|
||||||
QCOMPARE(dt1.offsetFromUtc(), 60 * 60);
|
QCOMPARE(dt1.offsetFromUtc(), 60 * 60);
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QVERIFY(dt1.timeZone().isValid());
|
QVERIFY(dt1.timeZone().isValid());
|
||||||
|
#endif
|
||||||
dt1 = QDateTime(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, -60 * 60);
|
dt1 = QDateTime(QDate(2013, 1, 1), QTime(1, 0, 0), Qt::OffsetFromUTC, -60 * 60);
|
||||||
QCOMPARE(dt1.offsetFromUtc(), -60 * 60);
|
QCOMPARE(dt1.offsetFromUtc(), -60 * 60);
|
||||||
|
|
||||||
@ -2625,11 +2648,13 @@ void tst_QDateTime::offsetFromUtc()
|
|||||||
QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo");
|
QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Pacific/Auckland"));
|
QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Pacific/Auckland"));
|
||||||
QCOMPARE(dt5.offsetFromUtc(), 46800);
|
QCOMPARE(dt5.offsetFromUtc(), 46800);
|
||||||
|
|
||||||
QDateTime dt6(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Pacific/Auckland"));
|
QDateTime dt6(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Pacific/Auckland"));
|
||||||
QCOMPARE(dt6.offsetFromUtc(), 43200);
|
QCOMPARE(dt6.offsetFromUtc(), 43200);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::setOffsetFromUtc()
|
void tst_QDateTime::setOffsetFromUtc()
|
||||||
@ -2785,6 +2810,7 @@ void tst_QDateTime::zoneAtTime_data()
|
|||||||
|
|
||||||
void tst_QDateTime::zoneAtTime()
|
void tst_QDateTime::zoneAtTime()
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QFETCH(QByteArray, ianaID);
|
QFETCH(QByteArray, ianaID);
|
||||||
QFETCH(QDate, date);
|
QFETCH(QDate, date);
|
||||||
QFETCH(int, offset);
|
QFETCH(int, offset);
|
||||||
@ -2797,6 +2823,9 @@ void tst_QDateTime::zoneAtTime()
|
|||||||
QCOMPARE(zone.standardTimeOffset(QDateTime(date, noon, zone)), offset);
|
QCOMPARE(zone.standardTimeOffset(QDateTime(date, noon, zone)), offset);
|
||||||
else // zone.offsetFromUtc *does* include DST, even before epoch
|
else // zone.offsetFromUtc *does* include DST, even before epoch
|
||||||
QCOMPARE(zone.offsetFromUtc(QDateTime(date, noon, zone)), offset);
|
QCOMPARE(zone.offsetFromUtc(QDateTime(date, noon, zone)), offset);
|
||||||
|
#else
|
||||||
|
QSKIP("Needs timezone feature enabled");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::timeZoneAbbreviation()
|
void tst_QDateTime::timeZoneAbbreviation()
|
||||||
@ -2838,6 +2867,7 @@ void tst_QDateTime::timeZoneAbbreviation()
|
|||||||
const QString cest(QStringLiteral("CEST"));
|
const QString cest(QStringLiteral("CEST"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin"));
|
QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue);
|
QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue);
|
||||||
@ -2848,6 +2878,7 @@ void tst_QDateTime::timeZoneAbbreviation()
|
|||||||
QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue);
|
QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue);
|
||||||
#endif
|
#endif
|
||||||
QCOMPARE(dt6.timeZoneAbbreviation(), cest);
|
QCOMPARE(dt6.timeZoneAbbreviation(), cest);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::getDate()
|
void tst_QDateTime::getDate()
|
||||||
@ -3323,6 +3354,7 @@ void tst_QDateTime::daylightTransitions() const
|
|||||||
|
|
||||||
void tst_QDateTime::timeZones() const
|
void tst_QDateTime::timeZones() const
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTimeZone invalidTz = QTimeZone("Vulcan/ShiKahr");
|
QTimeZone invalidTz = QTimeZone("Vulcan/ShiKahr");
|
||||||
QCOMPARE(invalidTz.isValid(), false);
|
QCOMPARE(invalidTz.isValid(), false);
|
||||||
QDateTime invalidDateTime = QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0), invalidTz);
|
QDateTime invalidDateTime = QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0), invalidTz);
|
||||||
@ -3518,6 +3550,9 @@ void tst_QDateTime::timeZones() const
|
|||||||
QDateTime future(QDate(2015, 1, 1), QTime(0, 0, 0), sgt);
|
QDateTime future(QDate(2015, 1, 1), QTime(0, 0, 0), sgt);
|
||||||
QVERIFY(future.isValid());
|
QVERIFY(future.isValid());
|
||||||
QCOMPARE(future.offsetFromUtc(), 28800);
|
QCOMPARE(future.offsetFromUtc(), 28800);
|
||||||
|
#else
|
||||||
|
QSKIP("Needs timezone feature enabled");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::systemTimeZoneChange() const
|
void tst_QDateTime::systemTimeZoneChange() const
|
||||||
@ -3530,13 +3565,17 @@ void tst_QDateTime::systemTimeZoneChange() const
|
|||||||
|
|
||||||
QDateTime localDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime);
|
QDateTime localDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime);
|
||||||
QDateTime utcDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC);
|
QDateTime utcDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC);
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QDateTime tzDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane"));
|
QDateTime tzDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane"));
|
||||||
|
#endif
|
||||||
qint64 localMsecs = localDate.toMSecsSinceEpoch();
|
qint64 localMsecs = localDate.toMSecsSinceEpoch();
|
||||||
qint64 utcMsecs = utcDate.toMSecsSinceEpoch();
|
qint64 utcMsecs = utcDate.toMSecsSinceEpoch();
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
qint64 tzMsecs = tzDate.toMSecsSinceEpoch();
|
qint64 tzMsecs = tzDate.toMSecsSinceEpoch();
|
||||||
|
|
||||||
// check that Australia/Brisbane is known
|
// check that Australia/Brisbane is known
|
||||||
QVERIFY(tzDate.timeZone().isValid());
|
QVERIFY(tzDate.timeZone().isValid());
|
||||||
|
#endif
|
||||||
|
|
||||||
// Change to Indian time
|
// Change to Indian time
|
||||||
useZone.reset(QByteArray("IST-05:30"));
|
useZone.reset(QByteArray("IST-05:30"));
|
||||||
@ -3545,8 +3584,10 @@ void tst_QDateTime::systemTimeZoneChange() const
|
|||||||
QVERIFY(localMsecs != localDate.toMSecsSinceEpoch());
|
QVERIFY(localMsecs != localDate.toMSecsSinceEpoch());
|
||||||
QCOMPARE(utcDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC));
|
QCOMPARE(utcDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC));
|
||||||
QCOMPARE(utcDate.toMSecsSinceEpoch(), utcMsecs);
|
QCOMPARE(utcDate.toMSecsSinceEpoch(), utcMsecs);
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QCOMPARE(tzDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane")));
|
QCOMPARE(tzDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane")));
|
||||||
QCOMPARE(tzDate.toMSecsSinceEpoch(), tzMsecs);
|
QCOMPARE(tzDate.toMSecsSinceEpoch(), tzMsecs);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::invalid_data() const
|
void tst_QDateTime::invalid_data() const
|
||||||
@ -3561,6 +3602,7 @@ void tst_QDateTime::invalid_data() const
|
|||||||
QTest::newRow("UTC") << invalidDate.toUTC() << Qt::UTC << true;
|
QTest::newRow("UTC") << invalidDate.toUTC() << Qt::UTC << true;
|
||||||
QTest::newRow("offset")
|
QTest::newRow("offset")
|
||||||
<< invalidDate.toOffsetFromUtc(3600) << Qt::OffsetFromUTC << true;
|
<< invalidDate.toOffsetFromUtc(3600) << Qt::OffsetFromUTC << true;
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTest::newRow("CET")
|
QTest::newRow("CET")
|
||||||
<< invalidDate.toTimeZone(QTimeZone("Europe/Oslo")) << Qt::TimeZone << true;
|
<< invalidDate.toTimeZone(QTimeZone("Europe/Oslo")) << Qt::TimeZone << true;
|
||||||
|
|
||||||
@ -3571,6 +3613,7 @@ void tst_QDateTime::invalid_data() const
|
|||||||
<< QDateTime::fromMSecsSinceEpoch(42, QTimeZone()) << Qt::TimeZone << false;
|
<< QDateTime::fromMSecsSinceEpoch(42, QTimeZone()) << Qt::TimeZone << false;
|
||||||
QDateTime valid(QDate(1970, 1, 1), QTime(12, 0), Qt::UTC);
|
QDateTime valid(QDate(1970, 1, 1), QTime(12, 0), Qt::UTC);
|
||||||
QTest::newRow("tonozone") << valid.toTimeZone(QTimeZone()) << Qt::TimeZone << false;
|
QTest::newRow("tonozone") << valid.toTimeZone(QTimeZone()) << Qt::TimeZone << false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::invalid() const
|
void tst_QDateTime::invalid() const
|
||||||
@ -3584,7 +3627,9 @@ void tst_QDateTime::invalid() const
|
|||||||
if (!goodZone)
|
if (!goodZone)
|
||||||
QCOMPARE(when.toMSecsSinceEpoch(), 0);
|
QCOMPARE(when.toMSecsSinceEpoch(), 0);
|
||||||
QVERIFY(!when.isDaylightTime());
|
QVERIFY(!when.isDaylightTime());
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QCOMPARE(when.timeZone().isValid(), goodZone);
|
QCOMPARE(when.timeZone().isValid(), goodZone);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTime::range() const
|
void tst_QDateTime::range() const
|
||||||
|
@ -3,5 +3,5 @@ SUBDIRS = \
|
|||||||
qcalendar \
|
qcalendar \
|
||||||
qdate \
|
qdate \
|
||||||
qdatetime \
|
qdatetime \
|
||||||
qtime \
|
qtime
|
||||||
qtimezone
|
qtConfig(timezone): SUBDIRS += qtimezone
|
||||||
|
@ -140,8 +140,10 @@ void tst_toolsupport::offsets_data()
|
|||||||
<< pmm_to_offsetof(&QDateTimePrivate::m_status) << 4 << 4;
|
<< pmm_to_offsetof(&QDateTimePrivate::m_status) << 4 << 4;
|
||||||
QTest::newRow("QDateTimePrivate::m_offsetFromUtc")
|
QTest::newRow("QDateTimePrivate::m_offsetFromUtc")
|
||||||
<< pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 16 << 16;
|
<< pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 16 << 16;
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTest::newRow("QDateTimePrivate::m_timeZone")
|
QTest::newRow("QDateTimePrivate::m_timeZone")
|
||||||
<< pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 20 << 24;
|
<< pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 20 << 24;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // RUN_MEMBER_OFFSET_TEST
|
#endif // RUN_MEMBER_OFFSET_TEST
|
||||||
}
|
}
|
||||||
|
@ -4018,6 +4018,7 @@ void tst_QSqlQuery::QTBUG_36211()
|
|||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dtwtz timestamptz, dtwotz timestamp)").arg(tableName)));
|
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dtwtz timestamptz, dtwotz timestamp)").arg(tableName)));
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTimeZone l_tzBrazil("America/Sao_Paulo");
|
QTimeZone l_tzBrazil("America/Sao_Paulo");
|
||||||
QTimeZone l_tzChina("Asia/Shanghai");
|
QTimeZone l_tzChina("Asia/Shanghai");
|
||||||
QVERIFY(l_tzBrazil.isValid());
|
QVERIFY(l_tzBrazil.isValid());
|
||||||
@ -4044,6 +4045,7 @@ void tst_QSqlQuery::QTBUG_36211()
|
|||||||
QVERIFY(diff <= 1000 - keep);
|
QVERIFY(diff <= 1000 - keep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4546,6 +4548,7 @@ void tst_QSqlQuery::dateTime_data()
|
|||||||
QTest::addColumn<QList<QDateTime> >("initialDateTimes");
|
QTest::addColumn<QList<QDateTime> >("initialDateTimes");
|
||||||
QTest::addColumn<QList<QDateTime> >("expectedDateTimes");
|
QTest::addColumn<QList<QDateTime> >("expectedDateTimes");
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
// Using time zones which are highly unlikely to be the same as the testing machine's one
|
// Using time zones which are highly unlikely to be the same as the testing machine's one
|
||||||
// as it could pass as a result despite it.
|
// as it could pass as a result despite it.
|
||||||
// +8.5 hours from UTC to North Korea
|
// +8.5 hours from UTC to North Korea
|
||||||
@ -4553,17 +4556,37 @@ void tst_QSqlQuery::dateTime_data()
|
|||||||
// -8 hours from UTC to Belize
|
// -8 hours from UTC to Belize
|
||||||
const QTimeZone beforeUTCTimeZone(-28800);
|
const QTimeZone beforeUTCTimeZone(-28800);
|
||||||
const QTimeZone utcTimeZone("UTC");
|
const QTimeZone utcTimeZone("UTC");
|
||||||
const QDateTime dt(QDate(2015, 5, 18), QTime(4, 26, 30));
|
|
||||||
const QDateTime dtWithMS(QDate(2015, 5, 18), QTime(4, 26, 30, 500));
|
|
||||||
const QDateTime dtWithAfterTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), afterUTCTimeZone);
|
const QDateTime dtWithAfterTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), afterUTCTimeZone);
|
||||||
const QDateTime dtWithBeforeTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), beforeUTCTimeZone);
|
const QDateTime dtWithBeforeTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), beforeUTCTimeZone);
|
||||||
const QDateTime dtWithUTCTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), utcTimeZone);
|
const QDateTime dtWithUTCTZ(QDate(2015, 5, 18), QTime(4, 26, 30, 500), utcTimeZone);
|
||||||
const QList<QDateTime> dateTimes = { dt, dtWithMS, dtWithAfterTZ, dtWithBeforeTZ, dtWithUTCTZ };
|
#endif
|
||||||
const QList<QDateTime> expectedDateTimesLocalTZ = { dt, dtWithMS, dtWithAfterTZ.toLocalTime(),
|
const QDateTime dt(QDate(2015, 5, 18), QTime(4, 26, 30));
|
||||||
dtWithBeforeTZ.toLocalTime(),
|
const QDateTime dtWithMS(QDate(2015, 5, 18), QTime(4, 26, 30, 500));
|
||||||
dtWithUTCTZ.toLocalTime() };
|
const QList<QDateTime> dateTimes = {
|
||||||
const QList<QDateTime> expectedTimeStampDateTimes = { dt, dtWithMS, dtWithMS, dtWithMS, dtWithMS };
|
dt, dtWithMS,
|
||||||
const QList<QDateTime> expectedDateTimes = { dt, dt, dt, dt, dt };
|
#if QT_CONFIG(timezone)
|
||||||
|
dtWithAfterTZ, dtWithBeforeTZ, dtWithUTCTZ
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
const QList<QDateTime> expectedDateTimesLocalTZ = {
|
||||||
|
dt, dtWithMS,
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
|
dtWithAfterTZ.toLocalTime(), dtWithBeforeTZ.toLocalTime(), dtWithUTCTZ.toLocalTime()
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
const QList<QDateTime> expectedTimeStampDateTimes = {
|
||||||
|
dt, dtWithMS,
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
|
dtWithMS, dtWithMS, dtWithMS
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
const QList<QDateTime> expectedDateTimes = {
|
||||||
|
dt, dt,
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
|
dt, dt, dt
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
for (const QString &dbName : qAsConst(dbs.dbNames)) {
|
for (const QString &dbName : qAsConst(dbs.dbNames)) {
|
||||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||||
|
@ -1605,7 +1605,9 @@ void tst_QItemDelegate::dateTextForRole_data()
|
|||||||
// Ensure we exercise every time-spec variant:
|
// Ensure we exercise every time-spec variant:
|
||||||
QTest::newRow("local") << QDateTime(date, time, Qt::LocalTime);
|
QTest::newRow("local") << QDateTime(date, time, Qt::LocalTime);
|
||||||
QTest::newRow("UTC") << QDateTime(date, time, Qt::UTC);
|
QTest::newRow("UTC") << QDateTime(date, time, Qt::UTC);
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTest::newRow("zone") << QDateTime(date, time, QTimeZone("Europe/Dublin"));
|
QTest::newRow("zone") << QDateTime(date, time, QTimeZone("Europe/Dublin"));
|
||||||
|
#endif
|
||||||
QTest::newRow("offset") << QDateTime(date, time, Qt::OffsetFromUTC, 36000);
|
QTest::newRow("offset") << QDateTime(date, time, Qt::OffsetFromUTC, 36000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -4510,6 +4510,7 @@ void tst_QDateTimeEdit::stepModifierPressAndHold()
|
|||||||
QCOMPARE(value.toDate(), expectedDate);
|
QCOMPARE(value.toDate(), expectedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
/*
|
/*
|
||||||
The following tests verify correct handling of the spring forward gap; which
|
The following tests verify correct handling of the spring forward gap; which
|
||||||
hour is skipped, and on which day, depends on the local time zone. We try to
|
hour is skipped, and on which day, depends on the local time zone. We try to
|
||||||
@ -4535,6 +4536,7 @@ static QDateTime findSpring(int year, const QTimeZone &timeZone)
|
|||||||
|
|
||||||
return spring;
|
return spring;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Test that typing in a time that is invalid due to spring forward gap
|
Test that typing in a time that is invalid due to spring forward gap
|
||||||
@ -4542,6 +4544,7 @@ static QDateTime findSpring(int year, const QTimeZone &timeZone)
|
|||||||
*/
|
*/
|
||||||
void tst_QDateTimeEdit::springForward_data()
|
void tst_QDateTimeEdit::springForward_data()
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTest::addColumn<QDateTime>("start");
|
QTest::addColumn<QDateTime>("start");
|
||||||
QTest::addColumn<QAbstractSpinBox::CorrectionMode>("correctionMode");
|
QTest::addColumn<QAbstractSpinBox::CorrectionMode>("correctionMode");
|
||||||
QTest::addColumn<QTime>("inputTime");
|
QTest::addColumn<QTime>("inputTime");
|
||||||
@ -4589,10 +4592,14 @@ void tst_QDateTimeEdit::springForward_data()
|
|||||||
<< QAbstractSpinBox::CorrectToNearestValue
|
<< QAbstractSpinBox::CorrectToNearestValue
|
||||||
<< springGapMiddle
|
<< springGapMiddle
|
||||||
<< springTransition;
|
<< springTransition;
|
||||||
|
#else
|
||||||
|
QSKIP("Needs timezone feature enabled");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTimeEdit::springForward()
|
void tst_QDateTimeEdit::springForward()
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QFETCH(QDateTime, start);
|
QFETCH(QDateTime, start);
|
||||||
QFETCH(QAbstractSpinBox::CorrectionMode, correctionMode);
|
QFETCH(QAbstractSpinBox::CorrectionMode, correctionMode);
|
||||||
QFETCH(QTime, inputTime);
|
QFETCH(QTime, inputTime);
|
||||||
@ -4621,6 +4628,7 @@ void tst_QDateTimeEdit::springForward()
|
|||||||
QTest::keyClick(&edit, Qt::Key_Return, {});
|
QTest::keyClick(&edit, Qt::Key_Return, {});
|
||||||
|
|
||||||
QCOMPARE(edit.dateTime(), expected);
|
QCOMPARE(edit.dateTime(), expected);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -4632,6 +4640,7 @@ void tst_QDateTimeEdit::springForward()
|
|||||||
*/
|
*/
|
||||||
void tst_QDateTimeEdit::stepIntoDSTGap_data()
|
void tst_QDateTimeEdit::stepIntoDSTGap_data()
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTest::addColumn<QDateTime>("start");
|
QTest::addColumn<QDateTime>("start");
|
||||||
QTest::addColumn<QDateTimeEdit::Section>("section");
|
QTest::addColumn<QDateTimeEdit::Section>("section");
|
||||||
QTest::addColumn<int>("steps");
|
QTest::addColumn<int>("steps");
|
||||||
@ -4706,10 +4715,14 @@ void tst_QDateTimeEdit::stepIntoDSTGap_data()
|
|||||||
<< QDateTimeEdit::YearSection
|
<< QDateTimeEdit::YearSection
|
||||||
<< -1
|
<< -1
|
||||||
<< springTransition;
|
<< springTransition;
|
||||||
|
#else
|
||||||
|
QSKIP("Needs timezone feature enabled");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDateTimeEdit::stepIntoDSTGap()
|
void tst_QDateTimeEdit::stepIntoDSTGap()
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QFETCH(QDateTime, start);
|
QFETCH(QDateTime, start);
|
||||||
QFETCH(QDateTimeEdit::Section, section);
|
QFETCH(QDateTimeEdit::Section, section);
|
||||||
QFETCH(int, steps);
|
QFETCH(int, steps);
|
||||||
@ -4732,6 +4745,7 @@ void tst_QDateTimeEdit::stepIntoDSTGap()
|
|||||||
QTest::keyClick(&edit, steps > 0 ? Qt::Key_Up : Qt::Key_Down, {});
|
QTest::keyClick(&edit, steps > 0 ? Qt::Key_Up : Qt::Key_Down, {});
|
||||||
|
|
||||||
QCOMPARE(edit.dateTime(), end);
|
QCOMPARE(edit.dateTime(), end);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QDateTimeEdit)
|
QTEST_MAIN(tst_QDateTimeEdit)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user