the information i needed to access include the current time zone name (in my case, AUS Eastern Standard Time or AEST) and whether or not i am currently in daylight saving or not - either AUS Eastern Standard Time (AEST) or AUS Eastern Daylight time (AEDT).
The functions that provided the answers i needed are part of the following winapi:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
The documentation state that this function is valid for windows vista as a minimum, and the OS this app will be used on is windows 8 and above.
In freebasic's winbase.bi the necessary function is wrapped by the macro "#if _WIN32_WINNT = &h0602", and the function i needed is "GetDynamicTimeZoneInformation". The data i needed is in the content of the data structure, and by default this function is not accessible in win8+ 64bit. Here is the relevant section of the winbase.bi which includes my modification just before the macro:
Code: Select all
#define _TIMEZONEAPI_H_
const TIME_ZONE_ID_INVALID = cast(DWORD, &hffffffff)
type _TIME_ZONE_INFORMATION
Bias as LONG
StandardName as wstring * 32
StandardDate as SYSTEMTIME
StandardBias as LONG
DaylightName as wstring * 32
DaylightDate as SYSTEMTIME
DaylightBias as LONG
end type
type TIME_ZONE_INFORMATION as _TIME_ZONE_INFORMATION
type PTIME_ZONE_INFORMATION as _TIME_ZONE_INFORMATION ptr
type LPTIME_ZONE_INFORMATION as _TIME_ZONE_INFORMATION ptr
type _TIME_DYNAMIC_ZONE_INFORMATION
Bias as LONG
StandardName as wstring * 32
StandardDate as SYSTEMTIME
StandardBias as LONG
DaylightName as wstring * 32
DaylightDate as SYSTEMTIME
DaylightBias as LONG
TimeZoneKeyName as wstring * 128
DynamicDaylightTimeDisabled as WINBOOLEAN
end type
type DYNAMIC_TIME_ZONE_INFORMATION as _TIME_DYNAMIC_ZONE_INFORMATION
type PDYNAMIC_TIME_ZONE_INFORMATION as _TIME_DYNAMIC_ZONE_INFORMATION ptr
declare function SystemTimeToTzSpecificLocalTime(byval lpTimeZoneInformation as const TIME_ZONE_INFORMATION ptr, byval lpUniversalTime as const SYSTEMTIME ptr, byval lpLocalTime as LPSYSTEMTIME) as WINBOOL
declare function TzSpecificLocalTimeToSystemTime(byval lpTimeZoneInformation as const TIME_ZONE_INFORMATION ptr, byval lpLocalTime as const SYSTEMTIME ptr, byval lpUniversalTime as LPSYSTEMTIME) as WINBOOL
declare function FileTimeToSystemTime(byval lpFileTime as const FILETIME ptr, byval lpSystemTime as LPSYSTEMTIME) as WINBOOL
declare function SystemTimeToFileTime(byval lpSystemTime as const SYSTEMTIME ptr, byval lpFileTime as LPFILETIME) as WINBOOL
declare function GetTimeZoneInformation(byval lpTimeZoneInformation as LPTIME_ZONE_INFORMATION) as DWORD
'-- mod by as on 2 aug 2018 - pulling next func decl from next #if _win32... section------------------------------
declare function GetDynamicTimeZoneInformation(byval pTimeZoneInformation as PDYNAMIC_TIME_ZONE_INFORMATION) as DWORD
'-- mod by as on 2 aug 2018 - pulling next func decl from next #if _win32... section------------------------------
#if _WIN32_WINNT = &h0602
declare function GetDynamicTimeZoneInformation(byval pTimeZoneInformation as PDYNAMIC_TIME_ZONE_INFORMATION) as DWORD
declare function GetTimeZoneInformationForYear(byval wYear as USHORT, byval pdtzi as PDYNAMIC_TIME_ZONE_INFORMATION, byval ptzi as LPTIME_ZONE_INFORMATION) as WINBOOL
declare function EnumDynamicTimeZoneInformation(byval dwIndex as const DWORD, byval lpTimeZoneInformation as PDYNAMIC_TIME_ZONE_INFORMATION) as DWORD
declare function GetDynamicTimeZoneInformationEffectiveYears(byval lpTimeZoneInformation as const PDYNAMIC_TIME_ZONE_INFORMATION, byval FirstYear as LPDWORD, byval LastYear as LPDWORD) as DWORD
declare function SystemTimeToTzSpecificLocalTimeEx(byval lpTimeZoneInformation as const DYNAMIC_TIME_ZONE_INFORMATION ptr, byval lpUniversalTime as const SYSTEMTIME ptr, byval lpLocalTime as LPSYSTEMTIME) as WINBOOL
declare function TzSpecificLocalTimeToSystemTimeEx(byval lpTimeZoneInformation as const DYNAMIC_TIME_ZONE_INFORMATION ptr, byval lpLocalTime as const SYSTEMTIME ptr, byval lpUniversalTime as LPSYSTEMTIME) as WINBOOL
#endif
Code: Select all
#include "windows.bi" 'includes my modified winbase.bi
Dim DynamicTimeZoneInfo As DYNAMIC_TIME_ZONE_INFORMATION
Dim as double _ReturnValue
' The return value (0|1|2) tells me if i am currently in daylight savings time or not
_ReturnValue=GetDynamicTimeZoneInformation(@DynamicTimeZoneInfo)
Print "_ReturnValue=";_ReturnValue
' And the current time zone name is stored in the TimeZoneKeyName value
Print DynamicTimeZoneInfo.TimeZoneKeyName
I haven't worked out a suitable macro wrapper as yet (I'll start looking at this - suggestions ?).