-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Nice duration fix #2330
Nice duration fix #2330
Conversation
|
Hello @ChanceNCounter! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-10-02 05:58:13 UTC |
forslund
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving this!
I commented on a couple of small things in the code, also there is one of the test that's failing (seeTravis)
Could you add a couple of test cases with specific resolutions?
|
I'm considering the merits of rounding minutes to hours when |
forslund
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be working just fine. 👍
For the future we could add a TimeResolution.AUTO that sets resolution depending on the duration. But that's outside of the scope of this PR
Let's make the handle_duration a "private" function to so we can change the api if needed. Does keeping the keywords only thing make sense in that context?
|
That last commit should finally put a bow on it. I've got tests for most of the rest of util.format.py, but those can get their own PR. |
|
Thanks @ChanceNCounter, to you want to rebase and squash things into a logical order or should I just squash everything into a single commit? |
|
@forslund interesting question. I think you might as well squash; I'll tag my branch, just in case, but I don't think there's any history here worth preserving. |
|
One more round of edge cases coming. At least I'm finding them before the merge. |
- Companion enum: mycroft.util.format.TimeResolution offers YEARS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS - Will only return ms if MILLISECONDS is chosen. Default: SECONDS - Update tests
Add one more optional parameter: bool clock, always produces digital clock-like output. "0h 3m" becomes "0:03:00". Has no effect on resolutions YEARS or DAYS, and MINUTES won't print hrs.
5798435 to
8c50fe9
Compare
|
Squashed it down. Now merging. Big thanks @ChanceNCounter ! |
nice_duration heavily refactored:
Companion enum:
mycroft.util.format.TimeResolution
offers YEARS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS
Will only return ms if MILLISECONDS is chosen. Default: SECONDS
==== Fixed Issues ====
#2295
==== Tech Notes ====
Will break anything calling nice_duration() using positional arguments.I couldn't find anything that does that, so I don't think this will break
any code in the wild.
How to test
Best to test in the interpreter. Don't forget to import
mycroft.util.format.TimeResolution!Other examples not in docstring:
Contributor license agreement signed?
CLA [yes]