(value: Optional[str], error: Type[Exception])
| 87 | |
| 88 | |
| 89 | def _parse_timezone(value: Optional[str], error: Type[Exception]) -> Union[None, int, timezone]: |
| 90 | if value == 'Z': |
| 91 | return timezone.utc |
| 92 | elif value is not None: |
| 93 | offset_mins = int(value[-2:]) if len(value) > 3 else 0 |
| 94 | offset = 60 * int(value[1:3]) + offset_mins |
| 95 | if value[0] == '-': |
| 96 | offset = -offset |
| 97 | try: |
| 98 | return timezone(timedelta(minutes=offset)) |
| 99 | except ValueError: |
| 100 | raise error() |
| 101 | else: |
| 102 | return None |
| 103 | |
| 104 | |
| 105 | def parse_date(value: Union[date, StrBytesIntFloat]) -> date: |
no outgoing calls
no test coverage detected