-
-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
Hi all! Reopening this one here: naturaltime currently breaks on timezone-aware datetime input values, eg with tzinfo set. Lots of background and details in jmoiron/humanize#9, jmoiron/humanize#190, and jmoiron/humanize#22, among others.
Example stacktrace below. Reproduces on the latest released version, 4.1.0. Thank you for maintaining humanize, it's great!
>>> from datetime import datetime, timezone
>>> from humanize import naturaltime
>>> naturaltime(datetime.now(timezone.utc))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ryan/src/bridgy/local/lib/python3.9/site-packages/humanize/time.py", line 231, in naturaltime
date, delta = _date_and_delta(value, now=now)
File "/Users/ryan/src/bridgy/local/lib/python3.9/site-packages/humanize/time.py", line 71, in _date_and_delta
delta = now - value
TypeError: can't subtract offset-naive and offset-aware datetimesReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels