How to store UTC in CDateTimeCtrl?

My MFC application has a date picker dialog. When I initialize this dialog, I need to call CDateTimeCtrl :: SetTime () and I am trying to decide which argument to give. I have an array of integers representing year, month, day, hour and minute in UTC. Here's the important bit: the date picker should display the time in UTC, not local time. And when I call GetTime () later, I have to be sure that what I get can be considered UTC.

The SetTime () function has three overrides: the first is CTime *, the second is COleDateTime &, and the third is LPSYSTEMTIME. It looks like the CTime constructor will automatically convert its input to local time, while COleDateTime doesn't. It's true? And I think LPSYSTEMTIME is not really meant to be created manually? So, my best course for creating a COleDateTime from my array and passing it to a SetTime?

Considering I'm in London during the winter, how can I test these things to make sure they behave the way I want them to? Is there a way to temporarily pretend I'm in Chicago and check that it doesn't affect my choice of date?

+1


source to share


1 answer


I've been working on something like this for a long time. I believe I used COleDateTime. The real advantage was that it didn't automatically convert to local time.
If you really want to check something, try adjusting your timezone to Sydney, as we are now in Daylight Saving Time (UTC + 11). A change in hemisphere will test you!



+3


source







All Articles