Немного подробное решение, но оно работает, когда даются часы или нет:
(ЧЧ: ММ: СС.Милли) || (ММ: СС.Милли) || (СС.Милли) || (.Милли)
double parse_text_minutes_to_double(std::string original)
{
std::vector<std::string> hms;
std::size_t pos;
while(std::count(original.begin(), original.end(), ':') )
{
pos = original.find(':');
hms.push_back(original.substr(0, pos));
original = original.substr(pos+1);
}
int minutes_hours{};
double sec_and_milli = std::stof(original);
int iteration_count{};
while (!hms.empty())
{
++iteration_count;
int seconds_iteration = std::stoi(hms.back()) * std::pow(60, iteration_count);
hms.pop_back();
minutes_hours += seconds_iteration;
}
return minutes_hours + sec_and_milli;
}
int main()
{
std::string original("1:1:20.465");
double result = parse_text_minutes_to_double(original);
std::cout << result << std::endl;
}