Create a DateTime instance from a timestamp.
(timestamp: int | float, tz: str | Timezone = UTC)
| 284 | |
| 285 | |
| 286 | def 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 | |
| 302 | def duration( |
nothing calls this directly
no test coverage detected
searching dependent graphs…