SaleaeTime

A high-precision wall clock time.

The primary way to use this type is to subtract two SaleaeTime values to produce a SaleaeTimeDelta. Deltas may be freely added and subtracted from each other and converted to floating-point seconds. They can also be added to or subtracted from SaleaeTime values to produce an offset time.

duration = end_time - start_time  # SaleaeTimeDelta
offset = start_time + SaleaeTimeDelta(second=1)  # SaleaeTime

Methods

__init__(datetime: datetime, *, millisecond: float = 0, microsecond: float = 0, nanosecond: float = 0, picosecond: float = 0) -> None

Construct a SaleaeTime from a datetime and optional sub-millisecond values.

datetime
A Python datetime used as the base time.
millisecond
Additional milliseconds (can be fractional).
microsecond
Additional microseconds (can be fractional).
nanosecond
Additional nanoseconds (can be fractional).
picosecond
Additional picoseconds (can be fractional).
as_datetime() -> datetime

Convert to the nearest Python datetime value.

The returned datetime is always timezone-aware and in UTC. Use standard Python datetime conversion functions to get local time.

Returns
A timezone-aware UTC datetime.
AI/LLM users: see llms-extensions.txt for machine-readable documentation.