config/Data: cast to std::chrono::steady_clock::duration properly

Oh no, 3413d1bf23 was broken!  Instead of passing a number as
"seconds" to the duration constructor, it just abused the duration
constructor as cast operator, which caused custom state_file_interval
settings to be extremely short.
This commit is contained in:
Max Kellermann
2020-10-08 19:57:00 +02:00
parent d64729065e
commit 27cc7b352d
5 changed files with 50 additions and 10 deletions

View File

@@ -135,3 +135,11 @@ ParseSize(const char *s, std::size_t default_factor)
return value;
}
std::chrono::steady_clock::duration
ParseDuration(const char *s)
{
// TODO: allow unit suffixes
const std::chrono::seconds seconds(ParseLong(s));
return std::chrono::duration_cast<std::chrono::steady_clock::duration>(seconds);
}