Advertisement

10.28.2007 at 06:07AM PDT, ID: 22922908 | Points: 500
[x]
Attachment Details

Need to access timezone information

Asked by asburgoyne in C Programming Language, C++ Programming Language, C# Programming Language

Tags: timezone, time, zone

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(GetTimeZoneInformation(TZInfoArray))
   {
      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
 
 
Loading Advertisement...
 
[+][-]10.28.2007 at 07:45AM PDT, ID: 20164817

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.28.2007 at 07:50AM PDT, ID: 20164994

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.20.2008 at 04:04PM PST, ID: 20943573

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628