summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_win.cpp
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2023-01-25 22:29:33 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2023-01-30 23:10:25 +0400
commit763884cfb7be0cadd353cfa3b9b760d521851718 (patch)
tree673a83c1c1227fda286d305f33b0e3a8480718f6 /src/corelib/text/qlocale_win.cpp
parent0eea2238f37a5eaa83ada6cd262eceaed20e415c (diff)
Pass short time format to GetTimeFormat from GetLocaleInfo
TIME_NOSECONDS doesn't really switches to short time format, just removes the seconds from long time format Fixes: QTBUG-110627 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qlocale_win.cpp')
-rw-r--r--src/corelib/text/qlocale_win.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index ce482c1977..550f7dd464 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -482,11 +482,13 @@ QVariant QSystemLocalePrivate::toString(QTime time, QLocale::FormatType type)
DWORD flags = 0;
// keep the same conditional as timeFormat() above
- if (type == QLocale::ShortFormat)
- flags = TIME_NOSECONDS;
+ const QString format = type == QLocale::ShortFormat
+ ? getLocaleInfo(LOCALE_SSHORTTIME).toString()
+ : QString();
+ auto formatStr = reinterpret_cast<const wchar_t *>(format.isEmpty() ? nullptr : format.utf16());
wchar_t buf[255];
- if (getTimeFormat(flags, &st, NULL, buf, 255)) {
+ if (getTimeFormat(flags, &st, formatStr, buf, int(std::size(buf)))) {
QString text = QString::fromWCharArray(buf);
if (substitution() == SAlways)
text = substituteDigits(std::move(text));