diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-09-27 18:09:03 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-16 22:26:37 +0100 |
commit | 68ff352906645a7a1beb0fa7e1ce34fff167c762 (patch) | |
tree | ba7e0e6b8bb5ce07d7da51c0b1fffc82a3f54e87 /src/corelib/tools | |
parent | e6abf372c6c2514ec8d53fae13cc676d3b55dd00 (diff) |
Use the short time format of the current locale on Windows
Windows 7 and later have LOCALE_SSHORTTIME, which is what we need.
Task-number: QTBUG-33718
Change-Id: I4c3f113d17102a37fb752de56f06b312f27c7887
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qlocale_win.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 0730002ca3..3a083582c9 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -82,6 +82,9 @@ static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT); #ifndef LOCALE_SNATIVECOUNTRYNAME # define LOCALE_SNATIVECOUNTRYNAME 0x00000008 #endif +#ifndef LOCALE_SSHORTTIME +# define LOCALE_SSHORTTIME 0x00000079 +#endif struct QSystemLocalePrivate { @@ -258,7 +261,9 @@ QVariant QSystemLocalePrivate::timeFormat(QLocale::FormatType type) { switch (type) { case QLocale::ShortFormat: - return winToQtFormat(getLocaleInfo(LOCALE_STIMEFORMAT)); //### + if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) + return winToQtFormat(getLocaleInfo(LOCALE_SSHORTTIME)); + // fall through case QLocale::LongFormat: return winToQtFormat(getLocaleInfo(LOCALE_STIMEFORMAT)); case QLocale::NarrowFormat: @@ -341,7 +346,7 @@ QVariant QSystemLocalePrivate::toString(const QDate &date, QLocale::FormatType t return QString(); } -QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType) +QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType type) { SYSTEMTIME st; memset(&st, 0, sizeof(SYSTEMTIME)); @@ -351,6 +356,9 @@ QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType) st.wMilliseconds = 0; DWORD flags = 0; + // keep the same conditional as timeFormat() above + if (type == QLocale::ShortFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) + flags = TIME_NOSECONDS; wchar_t buf[255]; if (GetTimeFormat(lcid, flags, &st, NULL, buf, 255)) { |