Code Monkey home page Code Monkey logo

Comments (3)

xolox avatar xolox commented on June 10, 2024

Hi and thanks for the feedback!

The parse_timespan() and format_timespan() pair of functions is intended to parse and format time spans that "the average human" is likely to work with. This explains my choice of units: seconds, minutes, hours, days, weeks and years.

Wikipedia lists the formal orders of magnitude of time which includes units like nanoseconds, microseconds, milliseconds, kiloseconds, megaseconds, etc. These are not practical units for me to "think in" so I didn't include any of these. However I've just added support for parsing and formatting of milliseconds:

  • Parsing works as you would expect it to (your examples work)
  • Formatting defaults to rendering fractional seconds like "1.5 seconds" instead of "1 second and 500 milliseconds" because I believe the former to be more human friendly (also: backwards compatibility). You can however get output like "1 second and 500 milliseconds" by calling format_timespan(..., detailed=True).

I'm closing this issue because I believe the problem you reported is resolved. If you don't agree then feel free to reopen this issue or open a new one. Thanks again for the feedback!

PS. I wonder how long it will take before someone requests to add support for microseconds and/or nanoseconds :-).

from python-humanfriendly.

dreamflasher avatar dreamflasher commented on June 10, 2024

Hi Peter,

first and foremost: Thank you for adding this functionality so quickly.
I appreciate that you just added it, despite you not seeing a lot value. I needed it because I wanted to parse logs with time information, so yeah I'd assume outside of computer world you don't really need that, but when you work with logs milliseconds is the default (imagine measuring function calls).
I also believe that the output as you implemented is more humand friendly!

So again: Thank you very much for the quick solution, thank you for your great work!

Marcel

from python-humanfriendly.

turicas avatar turicas commented on June 10, 2024

You may use numericalunits to implement other units. ;)

from python-humanfriendly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.