Details
Description
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.