Module for converting between
datetime.timedelta
and Go's Duration strings.
$ pip install durationpy
ns
- nanosecondsus
- microsecondsms
- milliseconds
- secondm
- minuteh
- hour
# parse
td = durationpy.from_str("4h3m2s1ms")
# format
durationpy.to_str(td)
Note: nanosecond precision is lost because datetime.timedelta
uses microsecond resolution.