当前位置: 动力学知识库 > 问答 > 编程问答 >

utc - Create specific FILETIME struct in C++

问题描述:

I've done research on MSDN and this site relating to my question, but have been unsuccessful in finding a specific, non-hacky solution.

I would like to have the ability to create specific UTC FILETIME struct in C++. The user has the ability to specify a date (YYYY/MM/DD) and then I would like to have the time of this date be 00:00. So far, this is what I have:

FILETIME ft;

SYSTEMTIME st;

st.wYear = myYear;

st.wMonth = myMonth;

st.wDay = myDay;

st.wHour = 0;

st.wMinute = 0;

st.wSecond = 0;

st.wMilliseconds = 0;

SystemTimeToFileTime(&st, &ft);

The issue I run into is that the local time zone information is used on my machine to generate a FILETIME that is different from the specified YYYY/MM/DD 00:00. The goal is to have a FILETIME struct that contains this information so that it is not time zone dependent.

I've considered using GetTimeZoneInformation() to find the UTC offset and perform mathematical calculations to vary st.wHour, st.wMinute, and st.wSecond, but was unsure as to if there was a better solution to simply create a specific FILETIME instance.

EDIT:

The resultant output I seek is FILETIME structure with the given myYear, myMonth, and myDay, and "hardcoded" time of 00:00 (UTC).

分享给朋友:
您可能感兴趣的文章:
随机阅读: