70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
#ifndef PITIME_WIN_H
|
|
#define PITIME_WIN_H
|
|
|
|
#include "pibase.h"
|
|
#ifdef WINDOWS
|
|
|
|
#include "pitime.h"
|
|
#include <windows.h>
|
|
|
|
|
|
//inline PISystemTime SYSTEMTIME2PISystemTime(SYSTEMTIME &t) {
|
|
// PISystemTime st;
|
|
|
|
//}
|
|
|
|
inline PISystemTime FILETIME2PISystemTime(const FILETIME &t) {
|
|
PISystemTime st;
|
|
ullong lt = ullong(t.dwHighDateTime) * 0x100000000U + ullong(t.dwLowDateTime);
|
|
st.seconds = lt / 10000000U;
|
|
st.nanoseconds = (lt % 10000000U) * 100U;
|
|
return st;
|
|
}
|
|
|
|
|
|
|
|
inline PIDateTime SYSTEMTIME2PIDateTime(const SYSTEMTIME &t) {
|
|
PIDateTime dt;
|
|
dt.year = t.wYear;
|
|
dt.month = t.wMonth;
|
|
dt.day = t.wDay;
|
|
dt.hours = t.wHour;
|
|
dt.minutes = t.wMinute;
|
|
dt.seconds = t.wSecond;
|
|
dt.milliseconds = t.wMilliseconds;
|
|
return dt;
|
|
}
|
|
|
|
inline PIDateTime FILETIME2PIDateTime(const FILETIME &t) {
|
|
FILETIME lt;
|
|
SYSTEMTIME st;
|
|
FileTimeToLocalFileTime(&t, <);
|
|
FileTimeToSystemTime(<, &st);
|
|
return SYSTEMTIME2PIDateTime(st);
|
|
}
|
|
|
|
inline SYSTEMTIME PIDateTime2SYSTEMTIME(const PIDateTime &dt) {
|
|
SYSTEMTIME st;
|
|
st.wYear = dt.year;
|
|
st.wMonth = dt.month;
|
|
st.wDay = dt.day;
|
|
st.wHour = dt.hours;
|
|
st.wMinute = dt.minutes;
|
|
st.wSecond = dt.seconds;
|
|
st.wMilliseconds = dt.milliseconds;
|
|
return st;
|
|
}
|
|
|
|
inline FILETIME PIDateTime2FILETIME(const PIDateTime &dt) {
|
|
FILETIME lt, ret;
|
|
SYSTEMTIME st = PIDateTime2SYSTEMTIME(dt);
|
|
SystemTimeToFileTime(&st, <);
|
|
LocalFileTimeToFileTime(<, &ret);
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
#endif // WINDOWS
|
|
#endif // PITIME_WIN_H
|