Simplify construction of two QTime instances

Rather than default-constructing and later setting its .mds, just pass
the number of millis to the constructor.

Change-Id: I5e259ee99b1ba53c48d8d71f2b479001c26ab7a0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Edward Welbourne 2022-05-23 12:44:59 +02:00
parent 410b5bc238
commit 8375f33078
1 changed files with 2 additions and 4 deletions

View File

@ -4672,21 +4672,19 @@ QTime QTime::currentTime()
QDateTime QDateTime::currentDateTime()
{
QTime t;
SYSTEMTIME st = {};
GetLocalTime(&st);
QDate d(st.wYear, st.wMonth, st.wDay);
t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
QTime t(msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds));
return QDateTime(d, t);
}
QDateTime QDateTime::currentDateTimeUtc()
{
QTime t;
SYSTEMTIME st = {};
GetSystemTime(&st);
QDate d(st.wYear, st.wMonth, st.wDay);
t.mds = msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
QTime t(msecsFromDecomposed(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds));
return QDateTime(d, t, Qt::UTC);
}