MCPcopy
hub / github.com/danielgtaylor/python-betterproto / to_datetime

Method to_datetime

src/betterproto/__init__.py:1981–1986  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1979 return cls(seconds, us * 1000)
1980
1981 def to_datetime(self) -> datetime:
1982 # datetime.fromtimestamp() expects a timestamp in seconds, not microseconds
1983 # if we pass it as a floating point number, we will run into rounding errors
1984 # see also #407
1985 offset = timedelta(seconds=self.seconds, microseconds=self.nanos // 1000)
1986 return DATETIME_ZERO + offset
1987
1988 @staticmethod
1989 def timestamp_to_json(dt: datetime) -> str:

Callers 2

_postprocess_singleMethod · 0.80

Calls

no outgoing calls

Tested by 1