|
|
Making TIME_ZONE_INFORMATION find if Daylight savings is active
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);
}
|
|
0
|
|
|
|
Reply
|
nilly16 (22)
|
1/25/2010 3:43:38 AM |
|
On 25 jan, 04:43, Jimbo <nill...@yahoo.com> wrote:
> 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?
If you want to get time zones, they are stored in registry (HKLM/
Software/.../Time Zones) (managed by Time Zone Editor tool (http://
www.dynawell.com/download/reskit/microsoft/win2000/tzedit.zip))
You can call GetTimeZoneInformation() for the current one.
|
|
0
|
|
|
|
Reply
|
Christian
|
1/25/2010 8:56:11 PM
|
|
|
1 Replies
579 Views
(page loaded in 0.044 seconds)
|
|
|
|
|
|
|
|
|