Comments (3)
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.
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.
You may use numericalunits to implement other units. ;)
from python-humanfriendly.
Related Issues (20)
- Formatting large negative numbers minor issue HOT 1
- hide seconds
- Singular unit of 1.5 (should be plural?) HOT 2
- Dependency on pyreadline may cause breaking incompatibility in Python 3.9 HOT 2
- File sizes with thousand separators HOT 2
- Please do not import unittest HOT 1
- parse_size does not distinguish between bits and bytes
- README example should be updated to python3 HOT 1
- Cache prevents re-enabling ANSI support when a subprocess has disabled it
- ModuleNotFoundError: No module named 'humanfriendly'
- use unittest.mock instead of mock HOT 2
- concatenate - serial comma incorrectly used with two items
- test failures with pytest7: AttributeError: module 'humanfriendly.tests' has no attribute 'connect'
- error: Duplicate module named "humanfriendly.terminal.html"
- Add type annotations
- Millibyte support HOT 2
- issue with raise InvalidSize(format(msg, size, tokens))
- Abbreviations 'hr' and 'hrs' for hour unit missing in time_units
- module pipes is removed in python version 3.13 - Please use the subprocess module instead
- im just a n00b, especially with macOS, but should there be a .DS_STORE in .gitignore for MacOS environments?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-humanfriendly.