Closed chipsTM closed 2 years ago
Thanks! I used your code as a base and added this to Time.as
:
uint64 ParseRelativeTime(const string &in time)
{
uint64 ret = 0;
int indexms = time.IndexOf(".");
if (indexms != -1) {
ret += Text::ParseUInt64(time.SubStr(indexms + 1));
}
array<string> lhs;
if (indexms != -1) {
lhs = time.SubStr(0, indexms).Split(":");
} else {
lhs = time.Split(":");
}
for (int i = int(lhs.Length) - 1; i >= 0; i--) {
int m = int(lhs.Length) - 1 - i;
ret += Text::ParseUInt64(lhs[i]) * (60 ** m) * 1000;
}
return ret;
}
As a plugin developer I would like to make available a function to convert a relative time string and convert to a numerical score similar to that which is provided by the nadeo apis
Examples:
Time::ParseStr("6:01.103") => 361103
Time::ParseStr("0:51.158") => 51158
Time::ParseStr("12:56:09.493") => 46569493
My quick and dirty function for reference: