Return |datetime| instance offset from `datetime` by offset specified in `offset_str`. `offset_str` is a string like `'-07:00'`.
(cls, datetime: dt.datetime, offset_str: str)
| 211 | |
| 212 | @classmethod |
| 213 | def _offset_dt(cls, datetime: dt.datetime, offset_str: str): |
| 214 | """Return |datetime| instance offset from `datetime` by offset specified in `offset_str`. |
| 215 | |
| 216 | `offset_str` is a string like `'-07:00'`. |
| 217 | """ |
| 218 | match = cls._offset_pattern.match(offset_str) |
| 219 | if match is None: |
| 220 | raise ValueError(f"{repr(offset_str)} is not a valid offset string") |
| 221 | sign, hours_str, minutes_str = match.groups() |
| 222 | sign_factor = -1 if sign == "+" else 1 |
| 223 | hours = int(hours_str) * sign_factor |
| 224 | minutes = int(minutes_str) * sign_factor |
| 225 | td = dt.timedelta(hours=hours, minutes=minutes) |
| 226 | return datetime + td |
| 227 | |
| 228 | _offset_pattern = re.compile(r"([+-])(\d\d):(\d\d)") |
| 229 |
no outgoing calls
no test coverage detected