From 52d9ac02ba388289543806821ee705201cfa549c Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 8 Mar 2024 14:14:28 +0300 Subject: [PATCH] Split business opening hours by week days. --- td/generate/scheme/td_api.tl | 2 +- td/telegram/BusinessWorkHours.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index f69bcddef..aa2ef41d7 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -631,7 +631,7 @@ businessOpeningHours time_zone_id:string opening_hours:vector BusinessWorkHours::get_business if (is_empty()) { return nullptr; } - return td_api::make_object( - time_zone_id_, transform(work_hours_, [](const WorkHoursInterval &interval) { - return interval.get_business_opening_hours_interval_object(); - })); + vector> 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(time_zone_id_, std::move(intervals)); } telegram_api::object_ptr BusinessWorkHours::get_input_business_work_hours() const {