mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 15:26:59 +00:00
fix 0....2h being allowed as time format
This commit is contained in:
parent
bf7f1ef1a5
commit
c61816dfeb
@ -4,8 +4,8 @@
|
||||
|
||||
std::chrono::high_resolution_clock::duration ChronoWrapper::TimeFromStringWithLiteral(const std::string& time_str)
|
||||
{
|
||||
// const std::regex time_regex(R"((\d+)(min|ms|us|ns|[dhs]))"); //i.e one of: "25ns, 6us, 256ms, 2s, 13min, 69h, 356d" will get matched (only available in newer C++ versions)
|
||||
const std::regex time_regex(R"((\d+\.*\d*)(min|[dhs]))"); //i.e one of: "2.01s, 13min, 69h, 356.69d" will get matched
|
||||
// const std::regex time_regex(R"((\d+\.{0,1}\d*)(min|ms|us|ns|[dhs]))"); //i.e one of: "25ns, 6us, 256ms, 2s, 13min, 69h, 356d" will get matched (only available in newer C++ versions)
|
||||
const std::regex time_regex(R"((\d+\.{0,1}\d*)(min|[dhs]))"); //i.e one of: "2.01s, 13min, 69h, 356.69d" will get matched
|
||||
std::smatch match;
|
||||
float time_value;
|
||||
if (!std::regex_search(time_str, match, time_regex)) return std::chrono::nanoseconds(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user