MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / _parse_iso8601_interval

Function _parse_iso8601_interval

src/pendulum/parsing/__init__.py:210–236  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

208
209
210def _parse_iso8601_interval(text: str) -> _Interval:
211 if "/" not in text:
212 raise ParserError("Invalid interval")
213
214 first, last = text.split("/")
215
216 if not first or not last:
217 raise ParserError("Invalid interval.")
218
219 start = end = duration = None
220
221 if first[:1] == "P":
222 # duration/end
223 duration = parse_iso8601(first)
224 end = parse_iso8601(last)
225 elif last[:1] == "P":
226 # start/duration
227 start = parse_iso8601(first)
228 duration = parse_iso8601(last)
229 else:
230 # start/end
231 start = parse_iso8601(first)
232 end = parse_iso8601(last)
233
234 return _Interval(
235 cast("datetime", start), cast("datetime", end), cast("Duration", duration)
236 )
237
238
239__all__ = ["parse", "parse_iso8601"]

Callers 1

_parseFunction · 0.85

Calls 3

ParserErrorClass · 0.90
parse_iso8601Function · 0.90
_IntervalClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…