6.5.3 clean

This commit is contained in:
kleuter
2023-11-01 18:02:52 +01:00
parent bbe896803b
commit 7018d9e6c8
2170 changed files with 57471 additions and 43550 deletions

View File

@ -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)