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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
=
r"""
Parse input opening hours description.
Parameters
----------
- oh: Opening hours expression as defined in OSM (eg. "24/7"). See
https://wiki.openstreetmap.org/wiki/Key:opening_hours/specification
- timezone: Timezone where the physical place attached to these opening hours lives in. When
specified, operations on this expression will return dates attached to this timezone and
input times in other timezones will be converted.
- country: ISO code of the country this physical place lives in. This will be used to load a
calendar of local public holidays.
- coords: (latitude, longitude) of this place. When this is specified together with a timezone
sun events will be accurate (sunrise, sunset, dusk, dawn). By default, this will be used to
automatically detect the timezone and a country code.
- auto_country: If set to `True`, the country code will automatically be inferred from
coordinates when they are specified.
- auto_timezone: If set to `True`, the timezone will automatically be inferred from coordinates
when they are specified.
- max_interval_days: If specified, any change that is longer than the number of specified days
will be considered infinite. This may be useful if you need to evaluate a large amount of
complicated expressions and performance is critical. Even setting a value of a full year (366)
is worth it.
Raises
------
SyntaxError
Given string is not in valid opening hours format.
Examples
--------
>>> oh = OpeningHours("24/7")
>>> oh.is_open()
True
>>> dt = datetime.fromisoformat("2024-07-14 15:00")
>>> oh = OpeningHours("sunrise-sunset ; PH off", country="FR", coords=(48.8535, 2.34839))
>>> assert oh.is_closed(dt)
>>> assert oh.next_change(dt).replace(tzinfo=None) == datetime.fromisoformat("2024-07-15 06:03")
"""
r"""
The list of warnings that were emited while parsing the expression.
"""
...
r"""
Convert the expression into a normalized form. It will not affect the meaning of the
expression and might impact the performance of evaluations.
Examples
--------
>>> OpeningHours("24/7 ; Su closed").normalize()
OpeningHours("Mo-Sa")
"""
r"""
Get current state of the time domain together with current comment. The state can be either
"open", "closed" or "unknown".
Parameters
----------
- time: Base time for the evaluation, current time will be used if it is not specified.
Examples
--------
>>> OpeningHours("24/7 off").state()
(State.CLOSED, '')
"""
r"""
Check if current state is open.
Parameters
----------
- time: Base time for the evaluation, current time will be used if it is not specified.
Examples
--------
>>> OpeningHours("24/7").is_open()
True
"""
r"""
Check if current state is closed.
Parameters
----------
- time: Base time for the evaluation, current time will be used if it is not specified.
Examples
--------
>>> OpeningHours("24/7 off").is_closed()
True
"""
r"""
Check if current state is unknown.
Parameters
----------
- time: Base time for the evaluation, current time will be used if it is not specified.
Examples
--------
>>> OpeningHours("24/7 unknown").is_unknown()
True
"""
r"""
Get the date for next change of state.
If the date exceed the limit date, returns None.
Parameters
----------
- time: Base time for the evaluation, current time will be used if it is not specified.
Examples
--------
>>> OpeningHours("24/7").next_change() # None
>>> OpeningHours("2099Mo-Su 12:30-17:00").next_change()
datetime.datetime(2099, 1, 1, 12, 30)
"""
r"""
Give an iterator that yields successive time intervals of consistent
state.
Parameters
----------
- start: Initial time for the iterator, current time will be used if it is not specified.
- end: Maximal time for the iterator, the iterator will continue until year 9999 if it no
max is specified.
Examples
--------
>>> intervals = OpeningHours("2099Mo-Su 12:30-17:00").intervals()
>>> next(intervals)
(..., datetime.datetime(2099, 1, 1, 12, 30), State.CLOSED, '')
>>> next(intervals)
(datetime.datetime(2099, 1, 1, 12, 30), datetime.datetime(2099, 1, 1, 17, 0), State.OPEN, '')
"""
...
...
r"""
Specify the state of an opening hours interval.
"""
= ...
r"""
Currently open
"""
= ...
r"""
Currently closed
"""
= ...
r"""
May be open depending on context
"""
r"""
Validate that input string is a correct opening hours description.
Examples
--------
>>> opening_hours.validate("24/7")
True
>>> opening_hours.validate("24/24")
False
"""