From 31dc17c13a1977ce60bf9ec73a8762b0087c48df Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 25 Oct 2023 14:53:56 +0200 Subject: Rework massaging of time zone offsets in formatted date-times Add a missing std::move() and rearrange comments. Change-Id: I2d93e88f7b9b6f62e7d1cca5cacf794d2fef53b5 Reviewed-by: Paul Wicking Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/text') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 16a0341a7e..bdd000a452 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3593,14 +3593,14 @@ QString QCalendarBackend::dateTimeToString(QStringView format, const QDateTime & text = when.timeZone().displayName(when, QTimeZone::LongName); break; #endif // timezone - case 3: - case 2: + case 3: // ±hh:mm + case 2: // ±hhmm (we'll remove the ':' at the end) text = when.toOffsetFromUtc(when.offsetFromUtc()).timeZoneAbbreviation(); // If the offset is UTC that'll be a Qt::UTC, otherwise Qt::OffsetFromUTC. - Q_ASSERT(text.startsWith("UTC"_L1)); - // The Qt::UTC case omits the zero offset, which we want: - text = text.size() == 3 ? u"+00:00"_s : text.sliced(3); - if (repeat == 2) // +hhmm format, rather than +hh:mm format + Q_ASSERT(text.startsWith("UTC"_L1)); // Need to strip this. + // The Qt::UTC case omits the zero offset: + text = text.size() == 3 ? u"+00:00"_s : std::move(text).sliced(3); + if (repeat == 2) text = text.remove(u':'); break; default: -- cgit v1.2.3