diff options
| author | levlam <levlam@telegram.org> | 2024-03-08 14:14:28 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2024-03-08 14:14:28 +0300 |
| commit | 52d9ac02ba388289543806821ee705201cfa549c (patch) | |
| tree | 75f1b5ac0d3704cba1ed482be9346810af7c6d0c /td/telegram/BusinessWorkHours.cpp | |
| parent | 64094e17c02c965d9467124665daef197a789df1 (diff) | |
Split business opening hours by week days.
Diffstat (limited to 'td/telegram/BusinessWorkHours.cpp')
| -rw-r--r-- | td/telegram/BusinessWorkHours.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/td/telegram/BusinessWorkHours.cpp b/td/telegram/BusinessWorkHours.cpp index 67bf4773b..f4e6a34b8 100644 --- a/td/telegram/BusinessWorkHours.cpp +++ b/td/telegram/BusinessWorkHours.cpp @@ -54,10 +54,18 @@ td_api::object_ptr<td_api::businessOpeningHours> BusinessWorkHours::get_business if (is_empty()) { return nullptr; } - return td_api::make_object<td_api::businessOpeningHours>( - time_zone_id_, transform(work_hours_, [](const WorkHoursInterval &interval) { - return interval.get_business_opening_hours_interval_object(); - })); + vector<td_api::object_ptr<td_api::businessOpeningHoursInterval>> intervals; + for (const auto &work_hour : work_hours_) { + auto interval = work_hour; + while (interval.start_minute_ / (24 * 60) + 1 < interval.end_minute_ / (24 * 60)) { + auto prefix = interval; + prefix.end_minute_ = (interval.start_minute_ / (24 * 60) + 1) * 24 * 60; + interval.start_minute_ = prefix.end_minute_; + intervals.push_back(prefix.get_business_opening_hours_interval_object()); + } + intervals.push_back(interval.get_business_opening_hours_interval_object()); + } + return td_api::make_object<td_api::businessOpeningHours>(time_zone_id_, std::move(intervals)); } telegram_api::object_ptr<telegram_api::businessWorkHours> BusinessWorkHours::get_input_business_work_hours() const { |
