nano-duration
Tiny h/m/s ↔ seconds converter — ~1 KB, zero deps. Single-file, CLI included. Perfect for code-golf, minimal containers, or just for fun.
✨ Features
- ✅
2h 15m 3s→8103(seconds) - ✅
8103→2h15m3s - ✅ Accepts spaces/hybrids (
"1h5m","90s"," 2H "), case-insensitive - ✅ Zero dependencies, single tiny file
🚀 Usage
# Local (from repo)
python app_min.py "1h 5m 2s" # 3902
python app_min.py 3902 # 1h5m2s
python app_min.py 90 # 1m30s
After installing:
# CLI
pip install nano-duration
nano-duration "2h 15m 3s" # 8103
nano-duration 8103 # 2h15m3s
🤓 Why so small?
- Minimal regex ((\d+)\s*([hms])) + tiny map {h:3600,m:60,s:1}
- No heavy parsing; simple greedy division for formatting
- Single module + tiny CLI wrapper
🎉 Fun Ideas
- Sum durations in shell
echo $(( $(nano-duration "1h 2m") + $(nano-duration "35m") ))
# -> 5820
- Convert logs to readable
awk '{print $1}' times.txt | xargs -I{} nano-duration {} # each line seconds→hms
Notes Only h/m/s units are supported (no days/ms). Negative values are not recommended.
📜 License
MIT © 2025
Release files for nano-duration-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nano_duration_py-0.1.0.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nano_duration_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / nano_duration_py-0.1.0.tar.gz
| Download URL | nano_duration_py-0.1.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
159a9ec6eb4c0246cf694a9901baa87758bb4300e1e0320b723667d91a5116d2
|
|
BLAKE2b-256 checksum How to use checksums |
6e3b773cfe697780f9da7ba834daf3fc652b5f9c1024c537c249bc43a66bfe84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / nano_duration_py-0.1.0-py3-none-any.whl
| Download URL | nano_duration_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfe3532216327ddfc1d40503cc8a902fe9b3e217720c2ca709a8b11ce294a1b7
|
|
BLAKE2b-256 checksum How to use checksums |
f829fc1321a2cf39399fbf8d9863ba17dda2fce22c782c0ee863108e5b3a3f28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|