diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-12-29 03:35:41 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-28 17:35:41 -0500 |
| commit | ae6fa914aa2f43d39ae491ac7d3140dda69702fa (patch) | |
| tree | 8ecea479750200eed8f047381a167097404db8f9 /django/utils/duration.py | |
| parent | 46d1af2e82c2b2a6976397719afde33b5cff2498 (diff) | |
Fixed #28926 -- Fixed loss of precision of big DurationField values on SQLite and MySQL.
Diffstat (limited to 'django/utils/duration.py')
| -rw-r--r-- | django/utils/duration.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/utils/duration.py b/django/utils/duration.py index 53322b51d2..466603d46c 100644 --- a/django/utils/duration.py +++ b/django/utils/duration.py @@ -38,3 +38,7 @@ def duration_iso_string(duration): days, hours, minutes, seconds, microseconds = _get_duration_components(duration) ms = '.{:06d}'.format(microseconds) if microseconds else "" return '{}P{}DT{:02d}H{:02d}M{:02d}{}S'.format(sign, days, hours, minutes, seconds, ms) + + +def duration_microseconds(delta): + return (24 * 60 * 60 * delta.days + delta.seconds) * 1000000 + delta.microseconds |
