#34243: "TypeError: can't subtract offset-naive and offset-aware datetimes" when
using timesince() with USE_TZ=True and >1 month interval
-------------------------------+-----------------------------------------
Reporter: Sage Abdullah | Owner: Sage Abdullah
Type: Bug | Status: assigned
Component: Utilities | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Comment (by Sage Abdullah):
Whoops, sorry, I haven't properly tested the function as I currently don't
have a local Django dev environment.
I'm testing this on a shell with my Django project, I think this should be
reproducible:
{{{
>>> from django.utils import timezone
>>> from django.utils.timesince import timesince
>>> import datetime
>>> timesince(timezone.now() - datetime.timedelta(days=31))
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/sage/Code/github/wagtail/wagtail/venv/lib/python3.10/site-
packages/django/utils/timesince.py", line 103, in timesince
remaining_time = (now - pivot).total_seconds()
TypeError: can't subtract offset-naive and offset-aware datetimes
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34243#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018581b2284e-99f4cc85-4d91-4561-95b5-c5e5da26e5ad-000000%40eu-central-1.amazonses.com.