time64

The Python time standard uses POSIX (UNIX) time which is defined relative to Jan 1, 1970. Python uses floating point seconds to express time. This module defines a much simpler 64-bit fixed point integer for representing time which is much friendlier for microcontrollers. The value is 34Q30 with the upper 34 bits to represent whole seconds and the lower 30 bits to represent fractional seconds. A value of 2**30 (1 << 30) represents 1 second. This representation gives a resolution of 2 ** -30 (approximately 1 nanosecond) and a range of +/- 2 ** 33 (approximately 272 years). The value is signed to allow for simple arithmetic on the time either as a fixed value or as deltas.

For more details, see jsdrv/time.h.

pyjoulescope_driver.time64.as_datetime(t)[source]

Convert a time to a python UTC timestamp.

Parameters:

t – The time which can be: * datetime.datetime * python timestamp * integer Joulescope timestamp

pyjoulescope_driver.time64.as_time64(t)[source]

Convert a time to a Joulescope timestamp.

Parameters:

t – The time which can be: * datetime.datetime * python timestamp * integer Joulescope timestamp

pyjoulescope_driver.time64.as_timestamp(t)[source]

Convert a time to a python UTC timestamp.

Parameters:

t – The time which can be: * datetime.datetime * python timestamp * integer Joulescope timestamp

pyjoulescope_driver.time64.duration_to_seconds(d)[source]

Convert a duration to float seconds. :param d: The duration specification, which is one of:

  • A string formatted as fz where f is a valid floating-point value and z is either omitted, ‘s’, ‘m’, ‘h’, ‘d’.

  • An integer in seconds.

  • A floating-point value in seconds.

pyjoulescope_driver.time64.filename(extension=None, t=None)[source]

Construct a filename from the time.

Parameters:
  • extension – The filename extension, such as ‘.png’. None (default) uses ‘.jls’.

  • t – The time. None (default) uses the current time.

Returns:

The filename.

pyjoulescope_driver.time64.now()[source]

Get the current timestamp.

Returns:

The time64 representation of the current time.