Wrong value on calculating difference in hours between TimeCurrent() and TimeLocal() - page 2

 
wemersonrv: WHRoeder, i don't get the point with the 1800 added to the equation.
  1. How do you round a double to an int?
    int res = int(dbl + 0.5); // 0.49 + 0.50 = 0.99 -> 0
                              // 0.51 + 0.50 = 1.01 -> 1
  2. How do you round seconds to an int hours?
    int    seconds = BrokerTime - ComputerTime;
    double hours   = double(seconds) / 3600.0;
    int TimeOffset = int(hours + 0.5);
  3. How do you round a int seconds to an int hours using only integer operations?
    int seconds    = BrokerTime - ComputerTime;
    int TimeOffset = (seconds + 1800)/3600; // 0.5 * 3600 = 1800
 
Ok, thanks!
 

Hi all

Anything new I don't understand in mt5:

I stay in France and time is summer time for now : GMT+2

Time here is 11h25so GMT Time is 9h25

In my EA


datetime tps_local=TimeLocal();
datetime tps_GMT=TimeGMT();

TimeToString(tps_local,TIME_MINUTES) gives 9h25

TimeToString(tps_local,TIME_MINUTES) gives 9h25

TimeToString(tps_GMT,TIME_MINUTES) gives 7h25

What is wrong ?

 
arcenciel:

Hi all

Anything new I don't understand in mt5:

I stay in France and time is summer time for now : GMT+2

Time here is 11h25so GMT Time is 9h25

At the time that you posted GMT was 09:01, so it couldn't have been 09:25 GMT

Reason: