This commit is contained in:
2025-01-04 00:01:22 +03:30
parent 6e03d6d993
commit fbc232a2b7
4 changed files with 331 additions and 42 deletions
+105 -1
View File
@@ -5778,6 +5778,74 @@ string ToFormatString(
return result;
}
/**
* Converts an String Represetation of Time (00:00) to Date Time ..
*
* @param value: String ...
*
* @return ( datetime )
*/
datetime ParseDateTimeFromTimeString(string value)
{
//
datetime result = NULL;
//
if (!IsValid(value))
{
return result;
}
//
// Check Signalling Time ...
MqlDateTime cTime;
bool isTimeRecieved = TimeCurrent(cTime);
if (!isTimeRecieved)
{
return result;
}
//
// Split ...
string parts[];
int partsCount = SplitContent(
parts,
value,
":"
//
);
if (!IsValidSize(partsCount))
{
return result;
}
//
int hour = 0;
int minute = 0;
if (partsCount >= 1)
{
hour = (int)(parts[0]);
}
if (partsCount >= 2)
{
minute = (int)(parts[1]);
}
//
cTime.day_of_week = 0;
cTime.day_of_year = 0;
//
cTime.hour = hour;
cTime.min = minute;
//
result = StructToTime(cTime);
//
return result;
}
//
// Check Specific Time in Range of another Time ...
bool IsTimeInRange(
@@ -5791,7 +5859,7 @@ bool IsTimeInRange(
//
// Normallize Current Time ...
NormalizeTime(currentTime);
currentTime = NormalizeTime(currentTime);
//
result = !IsValid(startTime) &&
@@ -5821,6 +5889,42 @@ bool IsTimeInRange(
//
return result;
}
bool IsTimeInRange(
datetime currentTime,
string startTime,
string endTime //
)
{
//
bool result = false;
//
result = IsValid(startTime) &&
IsValid(endTime);
if (!result)
{
//
// Here Since there isnot provide any
// data source we pass result as true ...
result = true;
return result;
}
//
// Converts String Representation to Time ...
datetime st = ParseDateTimeFromTimeString(startTime);
datetime et = ParseDateTimeFromTimeString(endTime);
//
result = IsTimeInRange(
currentTime,
st,
et //
);
//
return result;
}
//
// Bar Times ...