nitypes.bintime
Binary time data types for NI Python APIs.
NI Binary Time Format
This module implements the NI Binary Time Format (NI-BTF), a high-resolution time format used by NI software.
An NI-BTF time value is a 128-bit fixed point number consisting of a 64-bit whole seconds part and a 64-bit fractional seconds part. There are two types of NI-BTF time values:
An NI-BTF absolute time represents a point in time as the number of seconds after midnight, January 1, 1904, UTC.
An NI-BTF time interval represents a difference between two points in time.
NI-BTF time types are also supported in LabVIEW, LabWindows/CVI, and .NET. You can use NI-BTF time to efficiently share high-resolution date-time information with other NI application development environments.
NI-BTF Python Data Types
DateTime: represents an NI-BTF absolute time as a Python object.DateTimeArray: an array ofDateTimevalues.TimeDelta: represents a NI-BTF time interval as a Python object.TimeDeltaArray: an array ofTimeDeltavalues.
NI-BTF NumPy Structured Data Types
CVIAbsoluteTimeDType and CVITimeIntervalDType are NumPy structured data type objects
representing the CVIAbsoluteTime and CVITimeInterval C structs. These structured data types
can be used to efficiently represent NI-BTF time values in NumPy arrays or pass them to/from C DLLs.
Warning
CVIAbsoluteTimeDType and CVITimeIntervalDType have the same layout and field
names, so NumPy and type checkers such as Mypy currently treat them as the same type.
NI-BTF versus hightime
NI also provides the hightime Python package, which extends the standard Python datetime
module to support up to yoctosecond precision.
nitypes.bintime is not a replacement for hightime. The two time formats have different
strengths and weaknesses.
hightimesupports local time zones and time-zone-naive times.bintimeonly supports UTC.hightimeclasses supports the same operations as the standarddatetimeclasses.bintimeclasses support a subset of the standarddatetimeoperations.hightimehas a larger memory footprint than NI-BTF.hightimeobjects are separately allocated from the heap.bintimeoffers the choice of separately allocated Python objects or a more compact NumPy representation that can store multiple timestamps in a single block of memory.hightimerequires conversion to/from NI-BTF when calling the NI driver C APIs from Python.nitypes.bintimeincludes reusable conversion routines for NI driver Python APIs to use.
NI-BTF versus numpy.datetime64
NumPy provides the numpy.datetime64 data type, which is even more compact than NI-BTF.
However, it has lower resolution than NI-BTF and is not interoperable with NI driver C APIs that use
NI-BTF.
Attributes
Type alias for the base type of |
|
NumPy structured data type for a |
|
Type alias for the base type of |
|
NumPy structured data type for a |
Classes
An absolute time in NI Binary Time Format (NI-BTF). |
|
A mutable array of |
|
A named tuple containing the whole seconds and fractional seconds parts of a time value. |
|
A duration, represented in NI Binary Time Format (NI-BTF). |
|
A mutable array of |
Package Contents
- nitypes.bintime.CVIAbsoluteTimeBase: typing_extensions.TypeAlias
Type alias for the base type of
CVIAbsoluteTimeDType, which isnumpy.void.
- nitypes.bintime.CVIAbsoluteTimeDType
NumPy structured data type for a
CVIAbsoluteTimeC struct.
- nitypes.bintime.CVITimeIntervalBase: typing_extensions.TypeAlias
Type alias for the base type of
CVITimeIntervalDType, which isnumpy.void.
- nitypes.bintime.CVITimeIntervalDType
NumPy structured data type for a
CVITimeIntervalC struct.