fix(decor): don't wrap styled ETA hours at 60 - #168
Merged
Merged
Conversation
I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
The hours component in the HHMMSS, HHMM and MMSS time producers was reduced modulo 60, so a remaining time of 70h rendered as 10:00:00 and every 60h boundary aliased onto the same output. Hours are the leading unit here, so they should show the total. Minutes and seconds keep the % 60 since they are subdivisions. Closes vbauerster#167
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.
Fixes #167.
The HHMMSS, HHMM and MMSS time producers in decor/eta.go apply % 60 to the hours, but hours are the leading unit so they shouldn't wrap. A remaining time of 70h rendered as 10:00:00, and every 60h boundary aliased onto the same output. In the MMSS case the wrapped value also made the hours > 0 check pick the wrong branch past 60h.
Dropped the modulo on hours only, minutes and seconds keep it since they are subdivisions. Added a table test over chooseTimeProducer for each style (those producers had no direct coverage before), including durations past 60h. The test fails on master and passes with the change.
Included the copyright waiver commit per CONTRIBUTING.