Open realtimeprojects opened 1 year ago
A workaround is to set the relative base with an explicit time zone (tested on Wednesday January 31st).
>>> import dateparser
>>> from datetime import datetime, timezone
>>> dateparser.parse("Thursday at 6pm")
datetime.datetime(2024, 1, 1, 18, 0)
>>> dateparser.parse("Thursday at 6pm", settings={"RELATIVE_BASE": datetime.now(timezone.utc)})
datetime.datetime(2024, 2, 1, 18, 0)
EDIT: This may have been because it's late enough in January, that changing the timezone pushed me over into February.
I have a hunch this change is what caused the issue: https://github.com/scrapinghub/dateparser/pull/1179
There is a change from datetime.datetime.utcnow()
to datetime.datetime.now(datetime.timezone.utc)
, which changes us from a naive timestamp to a timezone aware timestamp. Most notably here.
However, this is purely a hunch.
tested on 2023-11-27, 15:33 UTC:
v1.1.8:
v1.2.0: