1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// 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 {
class Td;
class BusinessWorkHours {
public:
BusinessWorkHours() = default;
explicit BusinessWorkHours(telegram_api::object_ptr<telegram_api::businessWorkHours> &&work_hours);
explicit BusinessWorkHours(td_api::object_ptr<td_api::businessOpeningHours> &&work_hours);
bool is_empty() const;
td_api::object_ptr<td_api::businessOpeningHours> get_business_opening_hours_object() const;
td_api::object_ptr<td_api::businessOpeningHours> get_local_business_opening_hours_object(Td *td) const;
telegram_api::object_ptr<telegram_api::businessWorkHours> get_input_business_work_hours() const;
int32 get_next_open_close_in(Td *td, int32 unix_time, bool is_close) const;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
private:
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) {
}
td_api::object_ptr<td_api::businessOpeningHoursInterval> get_business_opening_hours_interval_object() const;
telegram_api::object_ptr<telegram_api::businessWeeklyOpen> get_input_business_weekly_open() const;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
void sanitize_work_hours();
void combine_work_hour_intervals();
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 StringBuilder &operator<<(StringBuilder &string_builder, const WorkHoursInterval &interval);
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessWorkHours &work_hours);
vector<WorkHoursInterval> work_hours_;
string time_zone_id_;
};
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
|