Rockhopper-Technologies / enlighten

Enlighten Progress Bar for Python Console Apps
https://python-enlighten.readthedocs.io
Mozilla Public License 2.0
421 stars 25 forks source link

Round down partial seconds #61

Closed DJtheRedstoner closed 1 year ago

DJtheRedstoner commented 1 year ago

Previously, partial seconds could sometimes be rounded up by the formatter resulting in "XX:60" being displayed briefly. If we always round down first, we can avoid this.

avylove commented 1 year ago

Good catch and thanks for the PR! I think your solution would be effective, but I think we can do this more accurately with less processing with something like this:

minutes, seconds = divmod(round(seconds), 60)
hours, minutes = divmod(minutes, 60)
rtn = u'%02d:%02d' % (minutes, seconds)
DJtheRedstoner commented 1 year ago

That's a better approach, thanks.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (99f500d) 100.00% compared to head (2ddc168) 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #61 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 10 10 Lines 932 932 Branches 193 193 ========================================= Hits 932 932 ``` | [Files Changed](https://app.codecov.io/gh/Rockhopper-Technologies/enlighten/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Rockhopper-Technologies) | Coverage Δ | | |---|---|---| | [enlighten/\_util.py](https://app.codecov.io/gh/Rockhopper-Technologies/enlighten/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Rockhopper-Technologies#diff-ZW5saWdodGVuL191dGlsLnB5) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.