MCPcopy Index your code
hub / github.com/python/cpython / _parse_tz_delta

Function _parse_tz_delta

Lib/zoneinfo/_zoneinfo.py:753–776  ·  view source on GitHub ↗
(tz_delta)

Source from the content-addressed store, hash-verified

751
752
753def _parse_tz_delta(tz_delta):
754 match = re.fullmatch(
755 r"(?P<sign>[+-])?(?P<h>\d{1,3})(:(?P<m>\d{2})(:(?P<s>\d{2}))?)?",
756 tz_delta,
757 re.ASCII
758 )
759 # Anything passed to this function should already have hit an equivalent
760 # regular expression to find the section to parse.
761 assert match is not None, tz_delta
762
763 h, m, s = (int(v or 0) for v in match.group("h", "m", "s"))
764
765 total = h * 3600 + m * 60 + s
766
767 if h > 24:
768 raise ValueError(
769 f"Offset hours must be in [0, 24]: {tz_delta}"
770 )
771
772 # Yes, +5 maps to an offset of -5h
773 if match.group("sign") != "-":
774 total = -total
775
776 return total

Callers 1

_parse_tz_strFunction · 0.85

Calls 1

groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…