py-humantime
A production-ready Python package and CLI tool to convert between seconds and human-readable time strings.
Features
- Convert seconds to human-readable time (e.g.,
1h 2m 3s) - Convert human-readable time to seconds (e.g.,
1h 2m 3s→3723) - Simple, extensible, and dependency-free
- Usable as both a CLI tool and Python module
- Helpful error messages and input validation
- Fully tested and ready for PyPI/GitHub
Installation
pip install py-humantime
Development install
pip install .
CLI Usage
Convert seconds to human-readable:
py-humantime --to-human 4523 # → 1h 15m 23s
Convert human-readable to seconds:
py-humantime --to-seconds "1h 15m" # → 4500
Python Usage
from pyhumantime import seconds_to_human, human_to_seconds
print(seconds_to_human(4523)) # → '1h 15m 23s'
print(human_to_seconds("1h 15m 23s")) # → 4523
Error Handling Example
from pyhumantime import human_to_seconds
try:
print(human_to_seconds('notatime'))
except ValueError as e:
print('Error:', e)
Extensibility
- The core logic is OOP-based and can be extended to support new units (e.g., milliseconds, days) by subclassing or enhancing
HumanTimeConverterinpyhumantime/core.py.
Contributing
Pull requests and issues are welcome! Please add tests for new features or bug fixes.
License
MIT License
Metadata
Release files for py-humantime 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_humantime-0.1.4.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_humantime-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / py_humantime-0.1.4.tar.gz
| Download URL | py_humantime-0.1.4.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f516e08a0e6a690b458f656c7813a50333174590f6ddee06fb54d3034c42261c
|
|
BLAKE2b-256 checksum How to use checksums |
e6bf0ffe727b0e1d0d275e2e73f069e53d53cf1a58d3ea556a74c2c60d5e1dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / py_humantime-0.1.4-py3-none-any.whl
| Download URL | py_humantime-0.1.4-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aacdcdacdf9a35a81d5ebe3f77413870dc69753b5a891a10ec62ce4d61f196bc
|
|
BLAKE2b-256 checksum How to use checksums |
d16567a66414c776d1f71f17209eeae76fc814224df7a6c60e461599ca8763ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|