mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 00:05:25 +08:00
6.5.3 clean
This commit is contained in:
@ -3186,10 +3186,15 @@ void tst_QDateTime::fromStringStringFormat_localTimeZone_data()
|
||||
QTimeZone gmt("GMT");
|
||||
if (gmt.isValid()) {
|
||||
lacksRows = false;
|
||||
const bool fullyLocal = ([]() {
|
||||
TimeZoneRollback useZone("GMT");
|
||||
return QDateTime::currentDateTime().timeZoneAbbreviation() == u"GMT"_s;
|
||||
})();
|
||||
QTest::newRow("local-timezone-with-offset:GMT")
|
||||
<< QByteArrayLiteral("GMT")
|
||||
<< QString("2008-10-13 GMT 11.50") << QString("yyyy-MM-dd t hh.mm")
|
||||
<< QDateTime(QDate(2008, 10, 13), QTime(11, 50), gmt);
|
||||
<< QDateTime(QDate(2008, 10, 13), QTime(11, 50),
|
||||
fullyLocal ? QTimeZone(QTimeZone::LocalTime) : gmt);
|
||||
}
|
||||
QTimeZone helsinki("Europe/Helsinki");
|
||||
if (helsinki.isValid()) {
|
||||
|
@ -46,6 +46,7 @@ class tst_QDateTimeParser : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void reparse();
|
||||
void parseSection_data();
|
||||
void parseSection();
|
||||
|
||||
@ -53,6 +54,37 @@ private Q_SLOTS:
|
||||
void intermediateYear();
|
||||
};
|
||||
|
||||
void tst_QDateTimeParser::reparse()
|
||||
{
|
||||
const QDateTime when = QDate(2023, 6, 15).startOfDay();
|
||||
// QTBUG-114575: 6.2 through 6.5 got back a bogus Qt::TimeZone (with zero offset):
|
||||
const Qt::TimeSpec spec = ([](QStringView name) {
|
||||
// When local time is UTC or a fixed offset from it, the parser prefers
|
||||
// to interpret a UTC or offset suffix as such, rather than as local
|
||||
// time (thereby avoiding DST-ness checks). We have to match that here.
|
||||
if (name == QLatin1StringView("UTC"))
|
||||
return Qt::UTC;
|
||||
if (name.startsWith(u'+') || name.startsWith(u'-')) {
|
||||
if (std::all_of(name.begin() + 1, name.end(), [](QChar ch) { return ch == u'0'; }))
|
||||
return Qt::UTC;
|
||||
if (std::all_of(name.begin() + 1, name.end(), [](QChar ch) { return ch.isDigit(); }))
|
||||
return Qt::OffsetFromUTC;
|
||||
// Potential hh:mm offset ? Not yet seen as local tzname[] entry.
|
||||
}
|
||||
return Qt::LocalTime;
|
||||
})(when.timeZoneAbbreviation());
|
||||
|
||||
const QStringView format = u"dd/MM/yyyy HH:mm t";
|
||||
QDateTimeParser who(QMetaType::QDateTime, QDateTimeParser::DateTimeEdit);
|
||||
QVERIFY(who.parseFormat(format));
|
||||
const auto state = who.parse(when.toString(format), -1, when, false);
|
||||
QCOMPARE(state.state, QDateTimeParser::Acceptable);
|
||||
QVERIFY(!state.conflicts);
|
||||
QCOMPARE(state.padded, 0);
|
||||
QCOMPARE(state.value.timeSpec(), spec);
|
||||
QCOMPARE(state.value, when);
|
||||
}
|
||||
|
||||
void tst_QDateTimeParser::parseSection_data()
|
||||
{
|
||||
QTest::addColumn<QString>("format");
|
||||
@ -140,10 +172,12 @@ void tst_QDateTimeParser::intermediateYear()
|
||||
|
||||
QVERIFY(testParser.parseFormat(format));
|
||||
|
||||
// Indian/Cocos has a transition at the start of 1900, so it started this
|
||||
// day at 00:02:20, throwing a time offset into QDTP.
|
||||
QDateTime val(QDate(1900, 1, 1).startOfDay());
|
||||
const QDateTimeParser::StateNode tmp = testParser.parse(input, -1, val, false);
|
||||
QCOMPARE(tmp.state, QDateTimeParser::Intermediate);
|
||||
QCOMPARE(tmp.value, expected.startOfDay());
|
||||
QCOMPARE(tmp.value.date(), expected);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QDateTimeParser)
|
||||
|
@ -795,9 +795,9 @@ void tst_QTimeZone::checkOffset_data()
|
||||
{ "Etc/UTC", "post_uint32", 2106, 2, 7, 6, 28, 17, 0, 0 },
|
||||
{ "Etc/UTC", "initial", -292275056, 5, 16, 16, 47, 5, 0, 0 },
|
||||
{ "Etc/UTC", "final", 292278994, 8, 17, 7, 12, 55, 0, 0 },
|
||||
// Kiev: regression test for QTBUG-64122 (on MS):
|
||||
{ "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
|
||||
{ "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
|
||||
// Kyiv: regression test for QTBUG-64122 (on MS):
|
||||
{ "Europe/Kyiv", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
|
||||
{ "Europe/Kyiv", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
|
||||
};
|
||||
bool lacksRows = true;
|
||||
for (const auto &entry : table) {
|
||||
@ -940,8 +940,8 @@ void tst_QTimeZone::windowsId()
|
||||
list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City"
|
||||
<< "America/Matamoros" << "America/Menominee" << "America/North_Dakota/Beulah"
|
||||
<< "America/North_Dakota/Center" << "America/North_Dakota/New_Salem"
|
||||
<< "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute"
|
||||
<< "America/Winnipeg" << "CST6CDT";
|
||||
<< "America/Ojinaga" << "America/Rainy_River" << "America/Rankin_Inlet"
|
||||
<< "America/Resolute" << "America/Winnipeg" << "CST6CDT";
|
||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list);
|
||||
|
||||
// Check country with no match returns empty list
|
||||
@ -956,7 +956,7 @@ void tst_QTimeZone::windowsId()
|
||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list);
|
||||
|
||||
list.clear();
|
||||
list << "America/Matamoros";
|
||||
list << "America/Matamoros" << "America/Ojinaga";
|
||||
QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list);
|
||||
|
||||
list.clear();
|
||||
|
Reference in New Issue
Block a user