MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / from_timestamp

Function from_timestamp

src/pendulum/__init__.py:286–299  ·  view source on GitHub ↗

Create a DateTime instance from a timestamp.

(timestamp: int | float, tz: str | Timezone = UTC)

Source from the content-addressed store, hash-verified

284
285
286def from_timestamp(timestamp: int | float, tz: str | Timezone = UTC) -> DateTime:
287 """
288 Create a DateTime instance from a timestamp.
289 """
290 dt = _datetime.datetime.fromtimestamp(timestamp, tz=UTC)
291
292 dt = datetime(
293 dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond
294 )
295
296 if tz is not UTC or tz != "UTC":
297 dt = dt.in_timezone(tz)
298
299 return dt
300
301
302def duration(

Callers

nothing calls this directly

Calls 3

datetimeFunction · 0.85
in_timezoneMethod · 0.80
fromtimestampMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…