scala-library-next
scala-library-next copied to clipboard
FiniteDuration human representation
When debugging/inspecting code with timeouts/ellapsed times/etc using FiniteDuration seeing 2068493 seconds is not ergonomic, and in most cases unhelpful.
I suggest adding either of these things (or even everything):
-
A method that returns the duration per unit of time (
Map[TimeUnit, Double]). For the example above it would be:Map( TimeUnit.DAYS -> 23, TimeUnit.HOURS -> 22, TimeUnit.MINUTES -> 34, TimeUnit.SECONDS -> 53, ) -
A method that returns a human readable string of the above. Keeping with the example it would return:
23 days, 22 hours, 34 minutes, 53 seconds -
An approximate human readable string:
About 24 days. This method could have some sort of max allowed error function.
I like this option, seems to hit the debug use case and remain precise:
A method that returns a human readable string of the above. Keeping with the example it would return: 23 days, 22 hours, 34 minutes, 53 seconds
On Sat, Aug 20, 2022 at 12:41 AM Simão Martins @.***> wrote:
When debugging/inspecting code with timeouts/ellapsed times/etc using FiniteDuration seeing 2068493 seconds is not ergonomic, and in most cases unhelpful.
I suggest adding either of these things (or even everything):
A method that returns the duration per unit of time (Map[TimeUnit, Double]). For the example above it would be:
Map( TimeUnit.DAYS -> 23, TimeUnit.HOURS -> 22, TimeUnit.MINUTES -> 34, TimeUnit.SECONDS -> 53, )
A method that returns a human readable string of the above. Keeping with the example it would return: 23 days, 22 hours, 34 minutes, 53 seconds
An approximate human readable string: About 24 days. This method could have some sort of max allowed error function.
— Reply to this email directly, view it on GitHub https://github.com/scala/scala-library-next/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXJZDQLVYKGILRO2TBWVDVZ6MJTANCNFSM57A7ISLQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
A method that returns a human readable string of the above.
This seems the most useful. The Map can already be done fairly easily, and the conversion to human-readable text isn't something you want to have to bother with whenever you need this.
The approximate string wouldn't really be helpful for one of the most common places I could see using this: failing test case output.