From 813015d67e2557fa859a07930a9becec4e5f64a0 Mon Sep 17 00:00:00 2001 From: nessita <124304+nessita@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:16:33 -0300 Subject: Fixed #34483 -- Fixed timesince()/timeuntil() with timezone-aware dates and interval less than 1 day. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8. Thanks Lorenzo Peña for the report. --- django/utils/timesince.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'django') diff --git a/django/utils/timesince.py b/django/utils/timesince.py index 7a79e55ad9..94ba24d48a 100644 --- a/django/utils/timesince.py +++ b/django/utils/timesince.py @@ -77,7 +77,8 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2): # Get years and months. total_months = (now.year - d.year) * 12 + (now.month - d.month) - if d.day > now.day or (d.day == now.day and d.time() > now.time()): + time_delta = delta - datetime.timedelta(days=delta.days) + if d.day > now.day or (d.day == now.day and time_delta.total_seconds() < 0): total_months -= 1 years, months = divmod(total_months, 12) -- cgit v1.2.1