1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #34483 -- Fixed timesince()/timeuntil() with timezone-aware dates and interval less than 1 day.

Regression in 8d67e16493.

Thanks Lorenzo Peña for the report.
This commit is contained in:
nessita
2023-04-13 13:16:33 -03:00
committed by GitHub
parent 0976742087
commit 813015d67e
3 changed files with 23 additions and 1 deletions

View File

@@ -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)