MCPcopy
hub / github.com/openai/openai-python / _parse_timezone

Function _parse_timezone

src/openai/_utils/_datetime_parse.py:56–66  ·  view source on GitHub ↗
(value: Optional[str])

Source from the content-addressed store, hash-verified

54
55
56def _parse_timezone(value: Optional[str]) -> Union[None, int, timezone]:
57 if value == "Z":
58 return timezone.utc
59 elif value is not None:
60 offset_mins = int(value[-2:]) if len(value) > 3 else 0
61 offset = 60 * int(value[1:3]) + offset_mins
62 if value[0] == "-":
63 offset = -offset
64 return timezone(timedelta(minutes=offset))
65 else:
66 return None
67
68
69def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime:

Callers 1

parse_datetimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected