stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Broker-independent time-routine: LibGMT.h
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=225
Page 1 of 1
Author:  mbkennel [ Sat Jan 07, 2012 7:36 pm ]
Post subject:  Broker-independent time-routine: LibGMT.h

I'm reposting here a useful "include" library called LibGMT.h. It does broker-independent time computations. You can get local time & local day in GMT, London, New York & Tokyo, and it adjusts for daylight saving (with hard coded tables through about 10 years from now). It requires that your local Windows computer is set to proper timezone & time (most are & automatically updated), and that you allow DLL calls when running an indicator/EA.

Use: stick it in experts\include folder. Use #include <LibGMT.h> in your EA/indi code.

And yes I wrote it with my own ten fingers. Copyrighted & GPL licensed, meaning that any EA/indi which uses it must also be publicly released under compatible conditions. Contact me for terms if you have a different requirement.

From the comments:

Code: Select all

UTILITY FUNCTIONS
 
   datetime GMTseconds()       
            return the datetime (seconds since 1/1/1970) for GMT time zone.
   void MakeDayHHMM(datetime dt, int& day_of_week, int& hhmm) 
            set day_of_week and hhmm from 'dt'.
            
 USEFUL FUNCTIONS      
   
 void GetLocalDayHHMM(int& day_of_week, int& hhmm)
 void GetGMTDayHHMM(int& day_of_week, int& hhmm)
 void GetNewYorkDayHHMM(int& day_of_week, int& hhmm) 
 void GetLondonDayHHMM(int& day_of_week, int& hhmm) 
 void GetTokyoDayHHMM(int& day_of_week, int& hhmm) 

These get the day of week & time with respect to the local (computer's local),
GMT, NYC, London and Tokyo. 'hhmm' means an integer of 100*hour + minute, making
comparisons easy.

Look what function is NOT present: the server time which controls all the charts.
Why?  Because there is no automatic way to know the broker's time zone & daylight
saving adjustment.

Author:  Dozer [ Sat Jan 07, 2012 9:57 pm ]
Post subject:  Re: Broker-independent time-routine: LibGMT.h

Very useful library. Thank you! :D
All times are UTC Page 1 of 1