From ff3533e2e1eb981a9b7e65ce27d0753c276346f0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 12 Apr 2024 13:55:11 +0200 Subject: 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 Reviewed-by: Ahmad Samir --- src/corelib/time/qdatetimeparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 61707a3b2d..78520a51aa 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -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; } -- cgit v1.2.3