Skip to content

"now + 1 hour" returns a time in the past #1292

@powejam

Description

@powejam

My Python environment:

$ python --version
Python 3.12.3

$ pip show dateparser
Name: dateparser
Version: 1.2.2
Summary: Date parsing library designed to parse dates from HTML pages
Home-page: https://github.com/scrapinghub/dateparser
Author: Scrapinghub
Author-email: opensource@zyte.com
License: BSD
Location: /home/vscode/venv/lib/python3.12/site-packages
Requires: python-dateutil, pytz, regex, tzlocal
Required-by: 

My system timezone is GMT or europe/london:

$ timedatectl
               Local time: Thu 2025-12-18 10:12:29 GMT
           Universal time: Thu 2025-12-18 10:12:29 UTC
                 RTC time: Thu 2025-12-18 10:12:29
                Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

$ date
Thu Dec 18 10:13:01 GMT 2025

The following gives the correct time, but I would expect a timezone-aware datetime object to be returned. There is no timezone in the output:

>>> datetime.now(ZoneInfo('Europe/London')).strftime('%a, %b %d %Y at %H:%M:%S %Z')
'Thu, Dec 18 2025 at 10:18:50 GMT'
>>> dateparser.parse("now", settings={'TIMEZONE': 'Europe/London'}).strftime( '%a, %b %d %Y at %H:%M:%S %Z' )
'Thu, Dec 18 2025 at 10:18:51 '

This doesn't work. I would expect to see the time an hour in the future, but I get an hour in the past (and no timezone):

>>> datetime.now(ZoneInfo('Europe/London')).strftime('%a, %b %d %Y at %H:%M:%S %Z')
'Thu, Dec 18 2025 at 10:19:27 GMT'
>>> dateparser.parse("now + 1 hour", settings={'TIMEZONE': 'Europe/London'}).strftime( '%a, %b %d %Y at %H:%M:%S %Z' )
'Thu, Dec 18 2025 at 09:19:29 '

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions