Re: [Django] #34243: timesince() raises TypeError with USE_TZ=True and >1 month interval. (was: "TypeError: can't subtract offset-naive and offset-aware datetimes" when using timesince() with USE_TZ=True and >1 month interval)

4 views
Skip to first unread message

Django

unread,
Jan 5, 2023, 6:30:22 AM1/5/23
to django-...@googlegroups.com
#34243: timesince() raises TypeError with USE_TZ=True and >1 month interval.
---------------------------------+-----------------------------------------
Reporter: Sage Abdullah | Owner: Sage Abdullah
Type: Bug | Status: assigned
Component: Utilities | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Mariusz Felisiak):

* cc: GianpaoloBranca (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

OK, `with self.settings(USE_TZ=True)` was missing:
{{{#!python
@requires_tz_support
def test_long_interval_with_tz(self):
with self.settings(USE_TZ=True):
now = timezone.now()
d = now - datetime.timedelta(days=40)
self.assertEqual(timesince(d), "1\xa0month")
}}}

Regression in 8d67e16493c903adc9d049141028bc0fff43f8c8.

--
Ticket URL: <https://code.djangoproject.com/ticket/34243#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 5, 2023, 6:38:32 AM1/5/23
to django-...@googlegroups.com
#34243: timesince() raises TypeError with USE_TZ=True and >1 month interval.
---------------------------------+-----------------------------------------
Reporter: Sage Abdullah | Owner: Sage Abdullah
Type: Bug | Status: assigned
Component: Utilities | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Sage Abdullah):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Oops, ninja'd! I was adding `override_settings` to the ticket description.

--
Ticket URL: <https://code.djangoproject.com/ticket/34243#comment:6>

Reply all
Reply to author
Forward
0 new messages