You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 datetimes
The text was updated successfully, but these errors were encountered:
snarfed
changed the title
Support timezone-aware datetimes
naturaltime should support timezone-aware datetimes
May 10, 2022
snarfed
added a commit
to snarfed/webutil
that referenced
this issue
May 10, 2022
Hi all! Reopening this one here:
naturaltime
currently breaks on timezone-aware datetime input values, eg withtzinfo
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!
The text was updated successfully, but these errors were encountered: