X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ftime%2Fwindows%2Frawtime.cpp;fp=source%2Ftime%2Fwindows%2Frawtime.cpp;h=b6276f02988f68663b1ae3905de4c30d9d28a709;hp=0000000000000000000000000000000000000000;hb=609c9a508cfdc7b42c46c4f21d17639204165a00;hpb=b4806214e905752617691f851717033fd3f266c2 diff --git a/source/time/windows/rawtime.cpp b/source/time/windows/rawtime.cpp new file mode 100644 index 0000000..b6276f0 --- /dev/null +++ b/source/time/windows/rawtime.cpp @@ -0,0 +1,36 @@ +#include "rawtime.h" +#include "rawtime_private.h" + +namespace { + +/// Returns the unixtime epoch as filetime +Msp::Time::RawTime get_epoch() +{ + SYSTEMTIME st; + st.wYear = 1970; + st.wMonth = 1; + st.wDay = 1; + st.wHour = 0; + st.wMinute = 0; + st.wSecond = 0; + st.wMilliseconds = 0; + + FILETIME ft; + SystemTimeToFileTime(&st, &ft); + return (ft.dwLowDateTime+(static_cast(ft.dwHighDateTime)<<32))/10; +} + +} + +namespace Msp { +namespace Time { + +RawTime filetime_to_rawtime(const FILETIME &ft) +{ + static RawTime epoch = get_epoch(); + + return (ft.dwLowDateTime+(static_cast(ft.dwHighDateTime)<<32))/10-epoch; +} + +} // namespace Time +} // namespace Msp