From ae6fa914aa2f43d39ae491ac7d3140dda69702fa Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Fri, 29 Dec 2017 03:35:41 +0500 Subject: Fixed #28926 -- Fixed loss of precision of big DurationField values on SQLite and MySQL. --- django/utils/duration.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/utils') 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 -- cgit v1.3