Fix Market Sessions Timing Issues ...
This commit is contained in:
@@ -7942,7 +7942,8 @@ MqlDateTime GetCurrentTime()
|
||||
MqlDateTime result = {};
|
||||
|
||||
//
|
||||
TimeCurrent(result);
|
||||
datetime cTime = TimeCurrent();
|
||||
TimeToStruct(cTime, result);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -7976,10 +7977,86 @@ ulong GetCurrentTimeAsMilliSeconds()
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetLocalOffset()
|
||||
{
|
||||
//
|
||||
MqlDateTime cTimeStruct;
|
||||
datetime cTime = TimeCurrent(cTimeStruct);
|
||||
|
||||
//
|
||||
MqlDateTime cLTimeStruct;
|
||||
datetime cLTime = TimeLocal(cLTimeStruct);
|
||||
|
||||
//
|
||||
cTimeStruct.sec = 0;
|
||||
cTime = StructToTime(cTimeStruct);
|
||||
|
||||
//
|
||||
cLTimeStruct.sec = 0;
|
||||
cLTime = StructToTime(cLTimeStruct);
|
||||
|
||||
//
|
||||
int result = ((int)cLTime - (int)cTime);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int GetUTCRequiredTimeOffset()
|
||||
{
|
||||
//
|
||||
int utcOffset = TimeGMTOffset();
|
||||
int localOffset = GetLocalOffset();
|
||||
|
||||
//
|
||||
int result = utcOffset + localOffset;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
datetime GetUTCTime(
|
||||
datetime time = NULL,
|
||||
bool applyTradeServerTime = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
datetime result = NULL;
|
||||
|
||||
//
|
||||
NormalizeTime(time);
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
datetime cTimeLocal = TimeLocal();
|
||||
|
||||
//
|
||||
int cLocalOffset = ((int)cTimeLocal - (int)cTime);
|
||||
int gmtOffset = TimeGMTOffset();
|
||||
int offsetDelte = gmtOffset + cLocalOffset;
|
||||
int requiredUTCOffset = GetUTCRequiredTimeOffset();
|
||||
if (requiredUTCOffset > 0) {
|
||||
requiredUTCOffset = -1 * requiredUTCOffset;
|
||||
}
|
||||
|
||||
//
|
||||
int timeSeconds = (int)time;
|
||||
int resultSeconds = timeSeconds + requiredUTCOffset;
|
||||
|
||||
//
|
||||
result = (datetime)(resultSeconds);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve only Hour and Minute as String ...
|
||||
string GetTimeString(
|
||||
datetime time = NULL
|
||||
datetime time = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user