Skip to content

ozgunlu/nano-duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

nano-duration

PyPI License Size CI

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-py
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

About

Tiny h/m/s ↔ seconds converter in ~1KB of Python. Zero dependencies. Golf-friendly πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages