1. Set the short time format in intl.cpl as H:mm:ss
2. Check the result of
QLocale().toString(QDateTime::currentDateTime().time(), QLocale::ShortFormat);
Expected result: follows the format
Observed result: uses H:mm format
I was able to fix this with the following patch
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index cb7131667c..bc9a30e828 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -485,12 +485,12 @@ QVariant QSystemLocalePrivate::toString(QTime time, QLocale::FormatType type)
st.wMilliseconds = 0;
DWORD flags = 0;
- // keep the same conditional as timeFormat() above
- if (type == QLocale::ShortFormat)
- flags = TIME_NOSECONDS;
+ std::wstring format = type == QLocale::ShortFormat
+ ? getLocaleInfo(LOCALE_SSHORTTIME).toString().toStdWString()
+ : std::wstring();
wchar_t buf[255];
- if (getTimeFormat(flags, &st, NULL, buf, 255)) {
+ if (getTimeFormat(flags, &st, !format.empty() ? format.c_str() : NULL, buf, 255)) {
QString text = QString::fromWCharArray(buf);
if (substitution() == SAlways)
text = substituteDigits(std::move(text));
I can submit it to gerrit if it's the right fix.
| For Gerrit Dashboard: QTBUG-110627 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 456378,7 | Pass short time format to GetTimeFormat from GetLocaleInfo | dev | qt/qtbase | Status: MERGED | +2 | 0 |
| 457124,2 | Pass short time format to GetTimeFormat from GetLocaleInfo | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |
| 457125,2 | Pass short time format to GetTimeFormat from GetLocaleInfo | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
| 457131,3 | Pass short time format to GetTimeFormat from GetLocaleInfo | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |
| 457132,5 | Pass short time format to GetTimeFormat from GetLocaleInfo | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | -1 | 0 |
| 483563,1 | Pass short time format to GetTimeFormat from GetLocaleInfo | tqtc/lts-5.15-vxworks | qt/tqtc-qtbase | Status: ABANDONED | 0 | 0 |