(tz_delta)
| 751 | |
| 752 | |
| 753 | def _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 |
no test coverage detected
searching dependent graphs…