theguy0000 Posted December 2, 2006 Share Posted December 2, 2006 Hello, I have searched both the help file and the forums, but could not find an answer. How could I find the offset from GMT in hours of the computer's time zone? For example, if the computer is set to US Mountain time, it would give me "-7". I am trying to convert a given time to GMT. Thanks The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
theguy0000 Posted December 2, 2006 Author Share Posted December 2, 2006 oh yeah, and I'm on Windows XP Media Center 2005 SP2 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Developers Jos Posted December 2, 2006 Developers Share Posted December 2, 2006 http://msdn.microsoft.com/library/default....information.asp SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
theguy0000 Posted December 2, 2006 Author Share Posted December 2, 2006 http://msdn.microsoft.com/library/default....information.asphmm....i hate msdn...how could I use that in AutoIt? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
theguy0000 Posted December 2, 2006 Author Share Posted December 2, 2006 why does this topic keep dying? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Developers Jos Posted December 2, 2006 Developers Share Posted December 2, 2006 why does this topic keep dying?Looks like you have to put in the effort yourself to try and get the dllcall working ...You could check the Registry for some of the info on the timezone ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Zedna Posted December 2, 2006 Share Posted December 2, 2006 (edited) Look at my Radar.au3 project - it's in my signature.I used these API calls there. But I discovered that number of hours was in that structure wrongso I used only information about winter/summer time state from there.Here is code snippet from there:; take time shift for winter/summer time $TZI_struct = DllStructCreate("dword;char[64];int;int;int;int;int;int;int;int;dword;char[64];int;int;int;int;int;int;int;int;dword") $posun = DllCall("kernel32.dll","int","GetTimeZoneInformation","ptr",DllStructGetPtr($TZI_struct)) TZI_struct = 0 ; note: time shift (bias) in structure TZI isn't correct, so only state of winter/summer time Select Case $posun[0] = 0 $posun = "+?" ; can't get time shift Case $posun[0] = 1 $posun = "+1" ; winter time Case $posun[0] = 2 $posun = "+2" ; summer time EndSelect Edited December 2, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
NELyon Posted December 2, 2006 Share Posted December 2, 2006 hmm....i hate msdn...how could I use that in AutoIt?How could you hate MSDN? Link to comment Share on other sites More sharing options...
theguy0000 Posted December 2, 2006 Author Share Posted December 2, 2006 For those still interested, I figured it out: #include <string.au3> $zone = RegRead ("HKLM\SYSTEM\ControlSet001\Control\TimeZoneInformation", "StandardName") $disp = RegRead ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"&$zone, "Display") $aOffset = _StringBetween ($disp, "(", ")") $offset = $aOffset[0] $offset = StringReplace ($offset, "GMT", "") If $offset = "" Then $offset = "+00:00" $addSubtract = StringLeft ($offset, 1) $offset = StringTrimLeft ($offset, 1) $offsetSplit = StringSplit ($offset, ":") $offset_hour = $offsetSplit[1] $offset_mins = $offsetSplit[2] MsgBox (0, "", "Hours: "&$offset_hour&@CRLF&"Minutes: "&$offset_mins) Using this you can easily convert to gmt time. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
gcriaco Posted May 10, 2007 Share Posted May 10, 2007 (edited) Look at my Radar.au3 project - it's in my signature. I used these API calls there. But I discovered that number of hours was in that structure wrong so I used only information about winter/summer time state from there. Here is code snippet from there: ; take time shift for winter/summer time $TZI_struct = DllStructCreate("dword;char[64];int;int;int;int;int;int;int;int;dword;char[64];int;int;int;int;int;int;int;int;dword") $posun = DllCall("kernel32.dll","int","GetTimeZoneInformation","ptr",DllStructGetPtr($TZI_struct)) TZI_struct = 0 ; note: time shift (bias) in structure TZI isn't correct, so only state of winter/summer time Select Case $posun[0] = 0 $posun = "+?" ; can't get time shift Case $posun[0] = 1 $posun = "+1" ; winter time Case $posun[0] = 2 $posun = "+2" ; summer time EndSelect Any progress? The Registry method for getting the timezone doesn't work on the italian Windows version, because Time Zones are listed in english, while my TimeZoneInformation/StandardName is in italian. Here is the VB code that converts a GMT date to a TimeZone date I tried to mograte to AutoIt (with no success): Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation _ As TIME_ZONE_INFORMATION) As Long Private Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Public Type TIME_ZONE_INFORMATION Bias As Long StandardName(0 To ((32 * 2) - 1)) As Byte 'unicode StandardDate As SYSTEMTIME StandardBias As Long DaylightName(0 To ((32 * 2) - 1)) As Byte 'unicode DaylightDate As SYSTEMTIME DaylightBias As Long End Type Public Function dateTimeZone(dteGMT As Date) As Date Dim tzi As TIME_ZONE_INFORMATION Dim dwBias As Long Select Case GetTimeZoneInformation(tzi) Case TIME_ZONE_ID_DAYLIGHT dwBias = tzi.Bias + tzi.DaylightBias Case TIME_ZONE_ID_STANDARD dwBias = tzi.Bias + tzi.StandardBias Case Else dwBias = 0 End Select dateTimeZone = DateAdd("n", -dwBias, dteGMT) End Function Any help is appreciated. Thanks Peppe Edited May 10, 2007 by gcriaco Link to comment Share on other sites More sharing options...
PaulIA Posted May 10, 2007 Share Posted May 10, 2007 For those that are interested, Auto3Lib has all of the Windows Time API calls implemented. Here's a short list: _Time_DosDateTimeToFileTime: Converts MS-DOS date and time values to a file time _Time_FileTimeToDosDateTime: Converts MS-DOS date and time values to a file time _Time_FileTimeToLocalFileTime: Converts a file time based on the Coordinated Universal Time to a local file time _Time_FileTimeToSystemTime: Converts a file time to system time format _Time_GetFileTime: Retrieves the date and time that a file was created, accessed and modified _Time_GetLocalTime: Retrieves the current local date and time _Time_GetSystemTime: Retrieves the current system date and time expressed in UTC _Time_GetSystemTimeAdjustment: Determines whether the system is applying periodic time adjustments _Time_GetSystemTimeAsFileTime: Retrieves the current system date and time expressed in UTC _Time_GetSystemTimes: Retrieves system timing information _Time_GetTimeZoneInformation: Retrieves the current time zone settings _Time_LocalFileTimeToFileTime: Converts a local file time to a file time based on UTC _Time_SetFileTime: Sets the date and time that a file was created, accessed and modified _Time_SetLocalTime: Sets the current local date and time _Time_SetSystemTime: Sets the current system time and date, expressed in UTC _Time_SetSystemTimeAdjustment: Enables or disables periodic time adjustments to the system's time of day clock _Time_SetTimeZoneInformation: Sets the current time zone settings _Time_SystemTimeToFileTime: Converts a system time to file time format _Time_SystemTimeToTzSpecificLocalTime: Converts a UTC time to a specified time zone's corresponding local time _Time_TzSpecificLocalTimeToSystemTime: Converts a local time to a time in UTC Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
gcriaco Posted May 10, 2007 Share Posted May 10, 2007 (edited) For those that are interested, Auto3Lib has all of the Windows Time API calls implemented. Here's a short list: _Time_DosDateTimeToFileTime: Converts MS-DOS date and time values to a file time _Time_FileTimeToDosDateTime: Converts MS-DOS date and time values to a file time _Time_FileTimeToLocalFileTime: Converts a file time based on the Coordinated Universal Time to a local file time _Time_FileTimeToSystemTime: Converts a file time to system time format _Time_GetFileTime: Retrieves the date and time that a file was created, accessed and modified _Time_GetLocalTime: Retrieves the current local date and time _Time_GetSystemTime: Retrieves the current system date and time expressed in UTC _Time_GetSystemTimeAdjustment: Determines whether the system is applying periodic time adjustments _Time_GetSystemTimeAsFileTime: Retrieves the current system date and time expressed in UTC _Time_GetSystemTimes: Retrieves system timing information _Time_GetTimeZoneInformation: Retrieves the current time zone settings _Time_LocalFileTimeToFileTime: Converts a local file time to a file time based on UTC _Time_SetFileTime: Sets the date and time that a file was created, accessed and modified _Time_SetLocalTime: Sets the current local date and time _Time_SetSystemTime: Sets the current system time and date, expressed in UTC _Time_SetSystemTimeAdjustment: Enables or disables periodic time adjustments to the system's time of day clock _Time_SetTimeZoneInformation: Sets the current time zone settings _Time_SystemTimeToFileTime: Converts a system time to file time format _Time_SystemTimeToTzSpecificLocalTime: Converts a UTC time to a specified time zone's corresponding local time _Time_TzSpecificLocalTimeToSystemTime: Converts a local time to a time in UTC Thanks Paul. The function I need is _Time_GetTimeZoneInformation. It works perfectly. Your job is very awesome. Any plan to include your UDFs in the AutoIt package? IMHO there is no need to have 2 helpfiles, 2 setup, 2 sets of UDFs (sometimes similar), and so on. I know that is a big effort, but think that in this way the AutoIt community could use a better/simpler tool. Hope that you and any other interested Autoitter (Jdeb, Gafrost,...) agree. All the best Peppe Edited May 10, 2007 by gcriaco Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now