我有日期字符串,如2009-02-28 15:40:05 AEDST并希望将其转换为SYSTEMTIME结构。到目前为止,我有:如何使用win32 API在时区之间进行转换?
SYSTEMTIME st;
FILETIME ft;
SecureZeroMemory(&st, sizeof(st));
sscanf_s(contents, "%u-%u-%u %u:%u:%u",
&st.wYear,
&st.wMonth,
&st.wDay,
&st.wHour,
&st.wMinute,
&st.wSecond);
// Timezone correction
SystemTimeToFileTime(&st, &ft);
LocalFileTimeToFileTime(&ft, &ft);
FileTimeToSystemTime(&ft, &st);
但是我的本地时区不是AEDST。所以我需要能够在转换为UTC时指定时区。
不幸的是,你不能用win32 API来做到这一点...查看http://msdn.microsoft.com/en-us/library/ms725481(VS.85).aspx 你或者需要创建一个空变量并手动填写,或使用标准的C时间库。 – uzbones 2009-02-28 05:48:25