(duration)
| 29 | |
| 30 | |
| 31 | def 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 | |
| 45 | def duration_microseconds(delta): |