Skip to content

Commit

Permalink
Fix dotnet round to milliseconds for high microsecond values
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-kipawa committed Sep 24, 2024
1 parent e14a3db commit 5070e29
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mikeio1d/dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def from_dotnet_datetime(x, round_to_milliseconds=True):
# Round to milliseconds if requested
if round_to_milliseconds:
microseconds_rounded = round(time.microsecond, -3)
if microseconds_rounded == 10**6:
time += datetime.timedelta(seconds=1)
microseconds_rounded = 0
time = time.replace(microsecond=microseconds_rounded)

return time
Expand Down

0 comments on commit 5070e29

Please sign in to comment.