MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / FixedOffset

Class FixedOffset

bson/tz_util.py:24–52  ·  view source on GitHub ↗

Fixed offset timezone, in minutes east from UTC. Implementation based from the Python `standard library documentation `_. Defining __getinitargs__ enables pickling / copying.

Source from the content-addressed store, hash-verified

22
23
24class FixedOffset(tzinfo):
25 """Fixed offset timezone, in minutes east from UTC.
26
27 Implementation based from the Python `standard library documentation
28 <http://docs.python.org/library/datetime.html#tzinfo-objects>`_.
29 Defining __getinitargs__ enables pickling / copying.
30 """
31
32 def __init__(self, offset: Union[float, timedelta], name: str) -> None:
33 if isinstance(offset, timedelta):
34 self.__offset = offset
35 else:
36 self.__offset = timedelta(minutes=offset)
37 self.__name = name
38
39 def __getinitargs__(self) -> Tuple[timedelta, str]:
40 return self.__offset, self.__name
41
42 def __repr__(self) -> str:
43 return f"{self.__class__.__name__}({self.__offset!r}, {self.__name!r})"
44
45 def utcoffset(self, dt: Optional[datetime]) -> timedelta:
46 return self.__offset
47
48 def tzname(self, dt: Optional[datetime]) -> str:
49 return self.__name
50
51 def dst(self, dt: Optional[datetime]) -> timedelta:
52 return ZERO
53
54
55utc: FixedOffset = FixedOffset(0, "UTC")

Callers 9

test_datetimeMethod · 0.90
test_from_datetimeMethod · 0.90
test_aware_datetimeMethod · 0.90
test_local_datetimeMethod · 0.90
test_naive_decodeMethod · 0.90
test_tzinfoMethod · 0.90
tz_util.pyFile · 0.85

Calls

no outgoing calls

Tested by 8

test_datetimeMethod · 0.72
test_from_datetimeMethod · 0.72
test_aware_datetimeMethod · 0.72
test_local_datetimeMethod · 0.72
test_naive_decodeMethod · 0.72
test_tzinfoMethod · 0.72