tags:

views:

254

answers:

1

My MFC application has a dialogue with a date picker. When I initialise this dialogue, I need to call CDateTimeCtrl::SetTime() and I'm trying to decide what argument to give it. I have an array of integers representing a year, month, day, hour and minute in UTC. Here's the important bit: the date picker must display the time in UTC, not local time. And when I call GetTime() later, I need to be sure that what I get back can be treated as UTC.

The SetTime() function has three overrides: the first takes a CTime*, the second takes a COleDateTime& and the third takes an LPSYSTEMTIME. It looks as though CTime's constructor automatically converts its input to local time and that COleDateTime's one doesn't. Is that true? And I think LPSYSTEMTIME isn't really designed to be built by hand? So is my best course to build a COleDateTime from my array and pass it to SetTime?

Given that I'm in London in winter, how can I test these things to make sure they're behaving as I want them to? Is there a way to temporarily pretend I'm in Chicago and check that this doesn't affect my date picker?

+2  A: 

I worked a long time ago on something similar. I believe I used the COleDateTime. The real advantage was that it doesn't auto convert to local time.
If you really want to test things, try setting your timezone to Sydney time since we are now in daylight saving (UTC+11). The change in hemispheres will test you!

Anthony K