- time_t systemtime_to_time_t(const SYSTEMTIME& st)
- {
- struct tm gm = {st.wSecond, st.wMinute, st.wHour, st.wDay, st.wMonth-1, st.wYear-1900, st.wDayOfWeek, 0, 0};
- return mktime(&gm);
- }
- SYSTEMTIME time_t_to_systemtime(time_t t)
- {
- tm temptm = *localtime(&t);
- SYSTEMTIME st = {1900 + temptm.tm_year,
- 1 + temptm.tm_mon,
- temptm.tm_wday,
- temptm.tm_mday,
- temptm.tm_hour,
- temptm.tm_min,
- temptm.tm_sec,
- 0};
- return st;
- }
https://blog.csdn.net/hellokandy/article/details/51329446
MFC版本的计算两个SYSTEMTIME之间的时间差,返回毫秒:
- __int64 TimeDiff(SYSTEMTIME left, SYSTEMTIME right)
- {
- CTime tmLeft(left.wYear, left.wMonth, left.wDay, 0, 0, 0);
- CTime tmRight(right.wYear, right.wMonth, right.wDay, 0, 0, 0);
- CTimeSpan sp = tmLeft - tmRight;
- long MillisecondsL = (left.wHour*3600 + left.wMinute*60 + left.wSecond)*1000 + left.wMilliseconds;
- long MillisecondsR = (right.wHour*3600 + right.wMinute*60 + right.wSecond)*1000 + right.wMilliseconds;
- return (__int64)sp.GetDays()*86400000 + (MillisecondsL - MillisecondsR);//此处返回毫秒
- }
https://blog.csdn.net/hellokandy/article/details/51329183