1
0
Fork
You've already forked duration
0
Turns seconds into readable time using the real Gregorian calendar.
  • Python 100%
Danlino 0adfc2b65c [ 0.2.1 ] update original time format
fix: timestamp format for Windows users (%-d → .day)
2026年01月12日 14:50:11 +01:00
duration.py [ 0.2.1 ] update original time format 2026年01月12日 14:50:11 +01:00
LICENSE Initial commit 2025年12月22日 18:00:00 +01:00
README.md update README 2026年01月03日 18:34:26 +01:00

Usage:
$ duration 
usage: duration [-h] [-v] [-s] [-c N] [-w] [-W] [-D] [-a] [-r] [-R] [sec]
positional arguments:
 sec time interval in seconds
options:
 -h, --help show this help message and exit
 -v, --version show program's version number and exit
 -s, --short short units output format
 -c N, --count N maximum number of units in the output
 -w, --weeks weeks will also be used in the output
 -W, --max-weeks show weeks as the highest time unit
 -D, --max-days show days as the highest time unit
 -a, --add-and shows "and" before the last unit (long format)
 -r, --real-time show real date/time alongside relative
 -R, --real-only show real date/time
Example:
$ cut -d. -f1 /proc/uptime | duration
12 days, 4 hours, 57 minutes, 23 seconds
$ echo '123456789' | duration 
3 years, 10 months, 29 days, 21 hours, 33 minutes, 9 seconds
$ duration -s 123456789
3y, 10mo, 29d, 21h, 33min, 9s
$ duration -w 123456789
3 years, 10 months, 4 weeks, 1 day, 21 hours, 33 minutes, 9 seconds
$ duration -W 123456789
204 weeks, 21 hours, 33 minutes, 9 seconds
$ duration -D 123456789
1428 days, 21 hours, 33 minutes, 9 seconds
$ duration -c2 123456789
3 years, 10 months
$ duration -c3 -a 123456789
3 years, 10 months, and 29 days
$ duration -r 123456789
3 years, 10 months, 29 days, 21 hours, 33 minutes, 9 seconds (Tue, 25.Jan 2022 01:03)
$ duration -R 123456789
Tue, 25.Jan 2022 00:58