diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-05-19 16:39:29 +0200 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2021-05-25 22:55:14 +0200 |
commit | 55765898fe7eb467b5675709ee765c24d71df7d6 (patch) | |
tree | 198507bbd8ee8c3cc60891cdc59ac4d7d6526a8b /src/corelib/time/qdatetime.cpp | |
parent | e16afd66fc3923852bc74a416af8291e4e355e82 (diff) |
Initialize SYSTEMTIME to {} instead of memset()ing
Change-Id: Ic17b90d10d6b5b7f4610e904e18979fc1d658a0a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index ca79ce4bad..6e2476c5aa 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -4669,8 +4669,7 @@ static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = QDate QDate::currentDate() { - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetLocalTime(&st); return QDate(st.wYear, st.wMonth, st.wDay); } @@ -4678,8 +4677,7 @@ QDate QDate::currentDate() QTime QTime::currentTime() { QTime ct; - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetLocalTime(&st); ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); return ct; @@ -4688,8 +4686,7 @@ QTime QTime::currentTime() QDateTime QDateTime::currentDateTime() { QTime t; - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetLocalTime(&st); QDate d(st.wYear, st.wMonth, st.wDay); t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); @@ -4699,8 +4696,7 @@ QDateTime QDateTime::currentDateTime() QDateTime QDateTime::currentDateTimeUtc() { QTime t; - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetSystemTime(&st); QDate d(st.wYear, st.wMonth, st.wDay); t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); @@ -4709,8 +4705,7 @@ QDateTime QDateTime::currentDateTimeUtc() qint64 QDateTime::currentMSecsSinceEpoch() noexcept { - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetSystemTime(&st); const qint64 daysAfterEpoch = QDate(1970, 1, 1).daysTo(QDate(st.wYear, st.wMonth, st.wDay)); @@ -4720,8 +4715,7 @@ qint64 QDateTime::currentMSecsSinceEpoch() noexcept qint64 QDateTime::currentSecsSinceEpoch() noexcept { - SYSTEMTIME st; - memset(&st, 0, sizeof(SYSTEMTIME)); + SYSTEMTIME st = {}; GetSystemTime(&st); const qint64 daysAfterEpoch = QDate(1970, 1, 1).daysTo(QDate(st.wYear, st.wMonth, st.wDay)); |