KDateTime::currentUtcDateTime()
Peter Kümmel
syntheticpp at gmx.net
Fri Jul 28 10:08:07 BST 2006
David Jarvie wrote:
> On Thursday 27 Jul 2006 18:19, Peter Kümmel wrote:
>> Peter Kümmel wrote:
>>> Why could we not also use the unix code on windows?
>>> No problem with compiling.
>
> If the UNIX code works on Windows, fine. I simply copied from the way that
> QDateTime::currentDateTime() works, with suitable modification to fetch
> the UTC time rather than the local time. The Windows code is untested, but
> it's simple enough to be reasonably confident that it will work.
>
>>> KDateTime KDateTime::currentUtcDateTime()
>>> {
>>> #ifdef Q_OS_WIN
>>> memset(&st, 0, sizeof(SYSTEMTIME));
>>> GetSystemTime(&st);
>>> return KDateTime(QDate(st.wYear, st.wMonth, st.wDay),
>>> QTime(st.wHour, st.wMinute, st.wSecond,
> st.wMilliseconds),
>>> Spec(UTC));
>>> #else
>>> time_t t;
>>> ::time(&t);
>>> KDateTime result;
>>> result.setTime_t(static_cast(t));
>>> return result;
>>> #endif
>>> }
>>>
>>> Peter
>>>
>>>
>> Shouldn't the windows specific code not be part of the KDateTime
> constructor?
>
> The KDateTime constructor does not fetch the current time, so there is no
> reason why this code should be in the constructor.
>
OK, so the windows code does too much, and we could remove it.
Peter
> --
> David Jarvie.
>
>
More information about the kde-core-devel
mailing list