Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hightime library #560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generated/nidaqmx/_grpc_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
_EPOCH_1970 = ht_datetime(1970, 1, 1, tzinfo=timezone.utc)

def convert_time_to_timestamp(dt: Union[std_datetime, ht_datetime], ts: Optional[GrpcTimestamp] = None) -> GrpcTimestamp:
seconds_since_1970 = int((dt - _EPOCH_1970).total_seconds())
# We need to add one more negative second if applicable to compensate for a non-zero microsecond.
if dt.microsecond and (dt < _EPOCH_1970):
seconds_since_1970 -=1
seconds_since_1970 = 0

if ts is None:
ts = GrpcTimestamp()

if isinstance(dt, ht_datetime):
seconds_since_1970 = int((dt - _EPOCH_1970).precision_total_seconds())
total_yoctoseconds = dt.yoctosecond
total_yoctoseconds += dt.femtosecond * _YS_PER_FS
total_yoctoseconds += dt.microsecond * _YS_PER_US
Expand All @@ -36,6 +35,7 @@ def convert_time_to_timestamp(dt: Union[std_datetime, ht_datetime], ts: Optional
if remainder_yoctoseconds >= _YS_PER_NS / 2:
nanos += 1
else:
seconds_since_1970 = int((dt - _EPOCH_1970).total_seconds())
nanos = dt.microsecond * _NS_PER_US

ts.FromNanoseconds(seconds_since_1970 * _NS_PER_S + nanos)
Expand Down
4 changes: 3 additions & 1 deletion generated/nidaqmx/_lib_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ class AbsoluteTime(ctypes.Structure):

@classmethod
def from_datetime(cls, dt: Union[std_datetime, ht_datetime]) -> AbsoluteTime:
seconds_since_1904 = int((dt - AbsoluteTime._EPOCH_1904).total_seconds())
seconds_since_1904 = 0

# Convert the subseconds.
if isinstance(dt, ht_datetime):
seconds_since_1904 = int((dt - AbsoluteTime._EPOCH_1904).precision_total_seconds())
total_yoctoseconds = dt.yoctosecond
total_yoctoseconds += dt.femtosecond * AbsoluteTime._YS_PER_FS
total_yoctoseconds += dt.microsecond * AbsoluteTime._YS_PER_US
lsb = int(
round(AbsoluteTime._NUM_SUBSECONDS * total_yoctoseconds / AbsoluteTime._YS_PER_S)
)
else:
seconds_since_1904 = int((dt - AbsoluteTime._EPOCH_1904).total_seconds())
lsb = int(
round(AbsoluteTime._NUM_SUBSECONDS * dt.microsecond / AbsoluteTime._US_PER_S)
)
Expand Down
6,087 changes: 3,044 additions & 3,043 deletions generated/nidaqmx/_stubs/nidaqmx_pb2.pyi

Large diffs are not rendered by default.

Loading
Loading