diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2024-04-12 13:55:11 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2024-04-19 13:56:37 +0200 |
commit | ff3533e2e1eb981a9b7e65ce27d0753c276346f0 (patch) | |
tree | 0d1f3d86578cdff75a9d4aed0a86cc1e8a1db8c5 | |
parent | 020ed1c435dce07b7f1894b89954d3b228b3f822 (diff) |
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>
-rw-r--r-- | src/corelib/time/qdatetimeparser.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; } |