常用的时间类型转换
在程序开发过程中不断会碰到不同的数据间的转换,在这里做一个总结: 一.时间类型间的转换: 1.time_t 转 FILETIME FILETIME ft; LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = (DWORD) ll; ft.dwHighDateTime = (DWORD)(ll >> 32); 2.FILETIME 转 time_t FILETIME ft; time_t t; LONGLONG llTime = ft.dwHighDateTime; llTime <<= 32; llTime |= ft.dwLowDateTime; t = (DWORD)((LONGLONG)(llTime - 116444736000000000) / 10000000); 3. SYSTEMTIME 转 FILETIME FILETIME ft; SYSTEMTIME st ; SystemTimeToFileTime( &st, &ft ); 4. FILETIME 转 SYSTEMTIME FILETIME ft; SYSTEMTIME st ; FileTimeToSystemTime( &ft, &st); 5.DATE 转 SYSTEMTIME DATE