Prefer QString::asprintf() over arg()'s padding variants

Marc assures me this is a better way to do the job. In due course,
this needs to be changed to use the locale of the datetime parser,
either using QLocale's private API or once QLocale exports suitable
API.

Task-number: QTBUG-122619
Change-Id: I5dbb5c309198d55a9786ecbec239d085f678afb9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Edward Welbourne 2024-04-12 13:55:11 +02:00
parent 020ed1c435
commit ff3533e2e1

View File

@ -1277,7 +1277,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, bool fixup) const
if (fixup && sect.state == Intermediate && sect.used < sn.count) {
const FieldInfo fi = fieldInfo(index);
if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
const QString newText = QString("%1"_L1).arg(sect.value, sn.count, 10, '0'_L1);
const QString newText = QString::asprintf("%0*d", sn.count, sect.value);
m_text.replace(pos, sect.used, newText);
sect.used = sn.count;
}