Prev: Windows Message sent when Mouse is no in Client Area OR NCClient area
Next: [C++ builder] Problem with TShape
From: Jimbo on 24 Jan 2010 22:43 Hello I am trying to use the Win32 function SystemTimeToTzSpecificLocalTime to get the time of a local city. And it works but, if the city is currently using daylight savings then my time comes out 1 hour behind. I have read in MSDN that i can use this function to take into account daylight savings IF I alter the TIME_ZONE_INFORMATION struct which is the 1st argument of the SystemTimeToTzSpecificLocalTime function. How can I alter a TIME_ZONE_INFORMATION struct to find if daylight savings will be active in a certain area? Dealing with all these windows structs & classes is sooo confusing :P Any suggestions or code how to do it would be really helpful. Maybe you could alter my code below? string controller::localTime() { // Post: Returns focus cities local time // NOTE AT PRESENT: function doesn't compensate for Daylight savings. Need 2 change this SYSTEMTIME ut, cityTime; TIME_ZONE_INFORMATION tz; tz.Bias = focusCity->bias; tz.StandardBias = 0; tz.DaylightBias = -60; /* unused TIME_ZONE_INFORMATION struct variables WCHAR StandardName[32]; SYSTEMTIME StandardDate; WCHAR DaylightName[32]; SYSTEMTIME DaylightDate; */ GetSystemTime(&ut); SystemTimeToTzSpecificLocalTime(&tz,&ut,&cityTime); } |