Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Latest commit

 

History

History
29 lines (20 loc) · 452 Bytes

README.md

File metadata and controls

29 lines (20 loc) · 452 Bytes

durationpy

Module for converting between datetime.timedelta and Go's Duration strings.

Install

$ pip install durationpy

Parse

  • ns - nanoseconds
  • us - microseconds
  • ms - millisecond
  • s - second
  • m - minute
  • h - hour
# parse
td = durationpy.from_str("4h3m2s1ms")

# format
durationpy.to_str(td)

Note: nanosecond precision is lost because datetime.timedelta uses microsecond resolution.