evanfoster / durationpy

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

License:MIT License


Languages

Language:Python 100.0%