summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r--src/corelib/tools/qlocale.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index dcdf6b5ed7..ab95f60115 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2742,14 +2742,17 @@ QString QLocalePrivate::dateTimeToString(const QString &format, const QDateTime
} else {
repeat = 1;
}
- switch (repeat) {
- case 1:
- result.append(m_data->longLongToString(time.msec()));
- break;
- case 3:
- result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded));
- break;
+
+ // note: the millisecond component is treated like the decimal part of the seconds
+ // so ms == 2 is always printed as "002", but ms == 200 can be either "2" or "200"
+ result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded));
+ if (repeat == 1) {
+ if (result.endsWith(zero()))
+ result.chop(1);
+ if (result.endsWith(zero()))
+ result.chop(1);
}
+
break;
case 't':