datetime_converter#

Reversible timestamp-to-integer codec for datetime, numpy.datetime64, and pandas.Timestamp.

class matviz.datetime_converter.DateCodec[source]#

Bases: object

Single-value, reversible timestamp <-> integer nanoseconds codec.

  • to_number(ts) -> int (ns since UNIX epoch, UTC)

  • from_number(ns) -> same type as input and same tz-awareness

from_number(ns: int)[source]#

Return the same type (datetime | np.datetime64 | pd.Timestamp) as the original input.

reset() None[source]#
to_number(ts) int[source]#

Accepts: datetime, np.datetime64, or pd.Timestamp. Returns int nanoseconds since epoch (UTC).