MCPcopy
hub / github.com/pydantic/pydantic / _parse_timezone

Function _parse_timezone

pydantic/v1/datetime_parse.py:89–102  ·  view source on GitHub ↗
(value: Optional[str], error: Type[Exception])

Source from the content-addressed store, hash-verified

87
88
89def _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
105def parse_date(value: Union[date, StrBytesIntFloat]) -> date:

Callers 2

parse_timeFunction · 0.85
parse_datetimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected