uataq.timerange.TimeRange.parse_iso#
- static TimeRange.parse_iso(string, inclusive=False)[source]#
Parse an ISO 8601 time string into a datetime.
Accepts
YYYY,YYYY-MM,YYYY-MM-DD, then aTor space andHH,HH:MM,HH:MM:SSorHH:MM:SS.ffffff. Dashes and colons may be left out (20240115), and a trailingZor+00:00is allowed; times are UTC.- Parameters:
string (
str) – The ISO 8601 formatted time string.inclusive (
bool) – If False (default), return the start of the period the string names. If True, return its end: one unit of the finest component given past the start, so"2024-01"ends at2024-02-01,"2024-01-15T12:30"at12:31, and"12:30:45.5"at12:30:45.6(one unit of the last fractional digit).
- Returns:
The parsed datetime.
- Return type:
- Raises:
ValueError – If the string is not in one of the accepted forms, carries a non-UTC offset, or names an impossible date.