MCPcopy
hub / github.com/django/django / duration_iso_string

Function duration_iso_string

django/utils/duration.py:31–42  ·  view source on GitHub ↗
(duration)

Source from the content-addressed store, hash-verified

29
30
31def duration_iso_string(duration):
32 if duration < datetime.timedelta(0):
33 sign = "-"
34 duration *= -1
35 else:
36 sign = ""
37
38 days, hours, minutes, seconds, microseconds = _get_duration_components(duration)
39 ms = ".{:06d}".format(microseconds) if microseconds else ""
40 return "{}P{}DT{:02d}H{:02d}M{:02d}{}S".format(
41 sign, days, hours, minutes, seconds, ms
42 )
43
44
45def duration_microseconds(delta):

Callers 10

defaultMethod · 0.90
quote_valueMethod · 0.90
test_simpleMethod · 0.90
test_daysMethod · 0.90
test_microsecondsMethod · 0.90
test_negativeMethod · 0.90
test_simpleMethod · 0.90
test_daysMethod · 0.90
test_microsecondsMethod · 0.90
test_negativeMethod · 0.90

Calls 2

_get_duration_componentsFunction · 0.85
formatMethod · 0.45

Tested by 8

test_simpleMethod · 0.72
test_daysMethod · 0.72
test_microsecondsMethod · 0.72
test_negativeMethod · 0.72
test_simpleMethod · 0.72
test_daysMethod · 0.72
test_microsecondsMethod · 0.72
test_negativeMethod · 0.72