2024-02-20 13:22:02 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2024-04-30 15:51:34 +02:00
|
|
|
class Td;
|
|
|
|
|
2024-02-20 13:22:02 +01:00
|
|
|
class BusinessWorkHours {
|
2024-02-26 15:06:29 +01:00
|
|
|
public:
|
|
|
|
BusinessWorkHours() = default;
|
|
|
|
|
|
|
|
explicit BusinessWorkHours(telegram_api::object_ptr<telegram_api::businessWorkHours> &&work_hours);
|
|
|
|
|
2024-02-27 14:03:34 +01:00
|
|
|
explicit BusinessWorkHours(td_api::object_ptr<td_api::businessOpeningHours> &&work_hours);
|
2024-02-26 15:06:29 +01:00
|
|
|
|
|
|
|
bool is_empty() const;
|
|
|
|
|
2024-02-27 14:03:34 +01:00
|
|
|
td_api::object_ptr<td_api::businessOpeningHours> get_business_opening_hours_object() const;
|
2024-02-26 15:06:29 +01:00
|
|
|
|
2024-04-30 15:51:34 +02:00
|
|
|
td_api::object_ptr<td_api::businessOpeningHours> get_local_business_opening_hours_object(Td *td) const;
|
|
|
|
|
2024-02-26 15:06:29 +01:00
|
|
|
telegram_api::object_ptr<telegram_api::businessWorkHours> get_input_business_work_hours() const;
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
|
|
|
|
private:
|
2024-02-20 13:22:02 +01:00
|
|
|
struct WorkHoursInterval {
|
|
|
|
int32 start_minute_ = 0;
|
|
|
|
int32 end_minute_ = 0;
|
|
|
|
|
|
|
|
WorkHoursInterval() = default;
|
|
|
|
WorkHoursInterval(int32 start_minute, int32 end_minute) : start_minute_(start_minute), end_minute_(end_minute) {
|
|
|
|
}
|
|
|
|
|
2024-02-27 14:03:34 +01:00
|
|
|
td_api::object_ptr<td_api::businessOpeningHoursInterval> get_business_opening_hours_interval_object() const;
|
2024-02-20 13:22:02 +01:00
|
|
|
|
2024-02-20 13:55:17 +01:00
|
|
|
telegram_api::object_ptr<telegram_api::businessWeeklyOpen> get_input_business_weekly_open() const;
|
|
|
|
|
2024-02-20 13:22:02 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2024-03-08 11:03:23 +01:00
|
|
|
void sanitize_work_hours();
|
|
|
|
|
|
|
|
void combine_work_hour_intervals();
|
|
|
|
|
2024-02-20 13:22:02 +01:00
|
|
|
friend bool operator==(const WorkHoursInterval &lhs, const WorkHoursInterval &rhs);
|
|
|
|
friend bool operator!=(const WorkHoursInterval &lhs, const WorkHoursInterval &rhs);
|
|
|
|
|
|
|
|
friend bool operator==(const BusinessWorkHours &lhs, const BusinessWorkHours &rhs);
|
|
|
|
friend bool operator!=(const BusinessWorkHours &lhs, const BusinessWorkHours &rhs);
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const WorkHoursInterval &interval);
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessWorkHours &work_hours);
|
|
|
|
|
2024-02-26 15:06:29 +01:00
|
|
|
vector<WorkHoursInterval> work_hours_;
|
|
|
|
string time_zone_id_;
|
2024-02-20 13:22:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const BusinessWorkHours::WorkHoursInterval &lhs, const BusinessWorkHours::WorkHoursInterval &rhs);
|
|
|
|
bool operator!=(const BusinessWorkHours::WorkHoursInterval &lhs, const BusinessWorkHours::WorkHoursInterval &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessWorkHours::WorkHoursInterval &interval);
|
|
|
|
|
|
|
|
bool operator==(const BusinessWorkHours &lhs, const BusinessWorkHours &rhs);
|
|
|
|
bool operator!=(const BusinessWorkHours &lhs, const BusinessWorkHours &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessWorkHours &work_hours);
|
|
|
|
|
|
|
|
} // namespace td
|