Repository navigation
Conversation
1.2 seconds was formatted as 1.199 because the millisecond product sits just under the integer.
boxerab
requested changes
Oct 29, 2026
boxerab
left a comment
Collaborator
There was a problem hiding this comment.
thanks, the bug is real. the epsilon plus the nested carry is more than this needs though. converting to whole milliseconds once handles the carry by itself:
total_milliseconds = round(s * 1000)
hours, remainder = divmod(total_milliseconds, 3_600_000)
minutes, remainder = divmod(remainder, 60_000)
seconds, milliseconds = divmod(remainder, 1000)this rounds to the nearest millisecond instead of truncating, so test_rounding_edge should expect 00:00:01,000 for 0.9999, and test_large_value can assert 23:59:59,999 exactly.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
format_time(1.2)came back as00:00:01,199.format_time(2.3)came back as00:00:02,299. The fractional seconds sit just under the millisecond, andint()drops it.format_time(1.5)is still00:00:01,500.format_time(0.9999)is still00:00:00,999.Red:
format_time(1.2)was00:00:01,199. Green:tests.test_utils.TestFormatTime, includingtest_tenth_of_a_second.