Tiny h/m/s ↔ seconds converter in ~1KB (zero deps)
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nano_duration_py-0.1.0.tar.gz.
File metadata
- Download URL: nano_duration_py-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
159a9ec6eb4c0246cf694a9901baa87758bb4300e1e0320b723667d91a5116d2
|
|
| MD5 |
3ff7ed6269fbd84c18b460d001a78936
|
|
| BLAKE2b-256 |
6e3b773cfe697780f9da7ba834daf3fc652b5f9c1024c537c249bc43a66bfe84
|
File details
Details for the file nano_duration_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nano_duration_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe3532216327ddfc1d40503cc8a902fe9b3e217720c2ca709a8b11ce294a1b7
|
|
| MD5 |
aecc4fdea81ddfb69c67d947c16d3b5c
|
|
| BLAKE2b-256 |
f829fc1321a2cf39399fbf8d9863ba17dda2fce22c782c0ee863108e5b3a3f28
|