Skip to content

Commit c909f34

Browse files
committed
resolve comment
1 parent d84aa84 commit c909f34

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

generated/nidaqmx/_time.py

Lines changed: 7 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+
femtosecond = getattr(expected_time_utc, "femtosecond", 0)
27+
yoctosecond = getattr(expected_time_utc, "yoctosecond", 0)
2628
desired_expected_time = ht_datetime(
2729
std_datetime_result.year,
2830
std_datetime_result.month,
@@ -31,10 +33,12 @@ 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+
yoctosecond,
38+
tzinfo=std_datetime_result.tzinfo,
39+
fold=std_datetime_result.fold
3640
)
37-
return desired_expected_time
41+
return desired_expected_time
3842

3943
# 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)
4044
elif tzinfo.utcoffset(None) is not None:

src/handwritten/_time.py

Lines changed: 5 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+
femtosecond = getattr(expected_time_utc, "femtosecond", 0)
27+
yoctosecond = getattr(expected_time_utc, "yoctosecond", 0)
2628
desired_expected_time = ht_datetime(
2729
std_datetime_result.year,
2830
std_datetime_result.month,
@@ -31,8 +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,
36+
femtosecond,
37+
yoctosecond,
3538
tzinfo=std_datetime_result.tzinfo,
39+
fold=std_datetime_result.fold
3640
)
3741
return desired_expected_time
3842

tests/unit/test_lib_time.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test___utc_datetime___convert_to_timestamp_with_dst___is_reversible(date):
118118
(ht_datetime(2023, 11, 5, tzinfo=timezone.utc), 1, 0x480F),
119119
],
120120
)
121-
def test___datetime_with_dst_and_femtoseconds___convert_to_timestamp___is_reversible(
121+
def test___utc_datetime_with_femtoseconds___convert_to_timestamp_with_dst___is_reversible(
122122
base_dt, femtosecond, subseconds
123123
):
124124
target_timezone = ZoneInfo("America/Los_Angeles")
@@ -130,12 +130,7 @@ def test___datetime_with_dst_and_femtoseconds___convert_to_timestamp___is_revers
130130

131131
assert ts.msb == LibTimestamp.from_datetime(expected_la_time).msb
132132
assert ts.lsb == subseconds
133-
# comparison is tricky since imprecision in the conversion to NI-BTF are
134-
# caught by the higher precision values in hightime, so we round here.
135-
roundtrip_dt_femtosecond = roundtrip_dt.femtosecond
136-
if roundtrip_dt.yoctosecond > LibTimestamp.MAX_YS / 2:
137-
roundtrip_dt_femtosecond += 1
138-
assert roundtrip_dt_femtosecond == femtosecond
133+
assert roundtrip_dt.femtosecond == expected_la_time.femtosecond
139134

140135

141136
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)