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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user