MCPcopy Create free account
hub / github.com/ByConity/ByConity / parseTimeWindow

Function parseTimeWindow

src/Statistics/AutoStatisticsManager.cpp:62–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::pair<Time, Time> parseTimeWindow(const String & text)
63{
64 auto throw_error = [&] {
65 auto err_msg = fmt::format(FMT_STRING("option {} has invalid value: '{}'"), Config::collect_window, text);
66 throw Exception(err_msg, ErrorCodes::BAD_ARGUMENTS);
67 };
68
69 // force HH:MM-HH:MM
70 if (text.size() != 11 || text[5] != '-')
71 {
72 throw_error();
73 }
74
75 auto begin_text = text.substr(0, 5);
76 auto begin_opt = getTimeFromString(begin_text);
77
78 if (!begin_opt.has_value())
79 throw_error();
80
81 auto end_text = text.substr(6, 5);
82 auto end_opt = getTimeFromString(end_text);
83
84 if (!end_opt.has_value())
85 throw_error();
86
87 return std::make_pair(begin_opt.value(), end_opt.value());
88}
89
90// parse other config for execution
91// refer to https://****

Callers 1

prepareNewConfigMethod · 0.85

Calls 5

getTimeFromStringFunction · 0.85
has_valueMethod · 0.80
ExceptionClass · 0.50
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected