]> git.tdb.fi Git - libs/core.git/blob - source/time/windows/rawtime.cpp
Simplify the SFINAE construct a bit
[libs/core.git] / source / time / windows / rawtime.cpp
1 #include "rawtime.h"
2 #include "rawtime_private.h"
3
4 namespace {
5
6 /// Returns the unixtime epoch as filetime
7 Msp::Time::RawTime get_epoch()
8 {
9         SYSTEMTIME st;
10         st.wYear = 1970;
11         st.wMonth = 1;
12         st.wDay = 1;
13         st.wHour = 0;
14         st.wMinute = 0;
15         st.wSecond = 0;
16         st.wMilliseconds = 0;
17
18         FILETIME ft;
19         SystemTimeToFileTime(&st, &ft);
20         return (ft.dwLowDateTime+(static_cast<Msp::Time::RawTime>(ft.dwHighDateTime)<<32))/10;
21 }
22
23 }
24
25 namespace Msp {
26 namespace Time {
27
28 RawTime filetime_to_rawtime(const FILETIME &ft)
29 {
30         static RawTime epoch = get_epoch();
31         
32         return (ft.dwLowDateTime+(static_cast<RawTime>(ft.dwHighDateTime)<<32))/10-epoch;
33 }
34
35 } // namespace Time
36 } // namespace Msp