I'm using the following code to get the difference between Local time and GMT so I can compute GMT time as "TimeCurrent() - TimeZoneLocal() * 3600". What I would like to do is be able to retrieve the timezone information for specified (i.e. not local) timezones. Can anyone help with this? The target platform is MQL (MetaQuote Language) used by the MT4 trading & financial modelling platform available free from
www.metaquotes.net#import "kernel32.dll"
int GetTimeZoneInformation(int
& TZInfoArray[]);
#import
#define TIME_ZONE_ID_UNKNOWN 0
#define TIME_ZONE_ID_STANDARD 1
#define TIME_ZONE_ID_DAYLIGHT 2
// Local timezone in hours, adjusting for daylight saving
double TimeZoneLocal()
{
int TZInfoArray[43];
switch(GetTimeZoneInformat
ion(TZInfo
Array))
{
case TIME_ZONE_ID_UNKNOWN:
return (TZInfoArray[0] / (-60.0));
Print("Error obtaining PC timezone from GetTimeZoneInformation in kernel32.dll. Returning 0");
return (0);
case TIME_ZONE_ID_STANDARD:
return (TZInfoArray[0] / (-60.0));
case TIME_ZONE_ID_DAYLIGHT:
return ((TZInfoArray[0] + TZInfoArray[42]) / (-60.0));
default:
Print("Unknown return value from GetTimeZoneInformation in kernel32.dll. Returning 0");
return (0);
}
}
Start Free Trial