Tiny h/m/s β seconds converter β ~1 KB, zero deps. Single-file, CLI included. Perfect for code-golf, minimal containers, or just for fun.
- β
2h 15m 3sβ8103(seconds) - β
8103β2h15m3s - β
Accepts spaces/hybrids (
"1h5m","90s"," 2H "), case-insensitive - β Zero dependencies, single tiny file
# Local (from repo)
python app_min.py "1h 5m 2s" # 3902
python app_min.py 3902 # 1h5m2s
python app_min.py 90 # 1m30sAfter installing:
# CLI
pip install nano-duration-py
nano-duration "2h 15m 3s" # 8103
nano-duration 8103 # 2h15m3s- 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
- 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βhmsNotes Only h/m/s units are supported (no days/ms). Negative values are not recommended.
MIT Β© 2025