Skip to content

Commit 70c5f77

Browse files
committed
getattr femtosecond
1 parent 6b8000c commit 70c5f77

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

generated/nidaqmx/_time.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def _convert_to_desired_timezone(
2323
if isinstance(tzinfo, ZoneInfo):
2424
localized_time = expected_time_utc.replace(tzinfo=tzinfo)
2525
std_datetime_result = tzinfo.fromutc(localized_time)
26+
# Preserve femtosecond precision from the original hightime datetime
27+
femtosecond = getattr(expected_time_utc, "femtosecond", 0)
2628
desired_expected_time = ht_datetime(
2729
std_datetime_result.year,
2830
std_datetime_result.month,
@@ -31,10 +33,10 @@ def _convert_to_desired_timezone(
3133
std_datetime_result.minute,
3234
std_datetime_result.second,
3335
std_datetime_result.microsecond,
34-
std_datetime_result.femtosecond,
35-
tzinfo=std_datetime_result.tzinfo
36+
femtosecond,
37+
tzinfo=std_datetime_result.tzinfo,
3638
)
37-
return desired_expected_time
39+
return desired_expected_time
3840

3941
# if the tzinfo passed in is a timedelta function, then we don't need to consider daylight savings # noqa: W505 - doc line too long (102 > 100 characters) (auto-generated noqa)
4042
elif tzinfo.utcoffset(None) is not None:

src/handwritten/_time.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def _convert_to_desired_timezone(
2323
if isinstance(tzinfo, ZoneInfo):
2424
localized_time = expected_time_utc.replace(tzinfo=tzinfo)
2525
std_datetime_result = tzinfo.fromutc(localized_time)
26+
# Preserve femtosecond precision from the original hightime datetime
27+
femtosecond = getattr(expected_time_utc, "femtosecond", 0)
2628
desired_expected_time = ht_datetime(
2729
std_datetime_result.year,
2830
std_datetime_result.month,
@@ -31,7 +33,7 @@ def _convert_to_desired_timezone(
3133
std_datetime_result.minute,
3234
std_datetime_result.second,
3335
std_datetime_result.microsecond,
34-
std_datetime_result.femtosecond,
36+
femtosecond,
3537
tzinfo=std_datetime_result.tzinfo,
3638
)
3739
return desired_expected_time

tests/unit/test_lib_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test___datetime_with_dst_and_femtoseconds___convert_to_timestamp___is_revers
135135
roundtrip_dt_femtosecond = roundtrip_dt.femtosecond
136136
if roundtrip_dt.yoctosecond > LibTimestamp.MAX_YS / 2:
137137
roundtrip_dt_femtosecond += 1
138-
assert roundtrip_dt_femtosecond == femtosecond
138+
assert roundtrip_dt_femtosecond == expected_la_time.femtosecond
139139

140140

141141
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)