| 60 | } |
| 61 | |
| 62 | std::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://**** |
no test coverage detected