Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returned datetime skips a day #1169

Closed
Baviaan opened this issue May 21, 2023 · 0 comments · Fixed by #1183
Closed

Returned datetime skips a day #1169

Baviaan opened this issue May 21, 2023 · 0 comments · Fixed by #1183

Comments

@Baviaan
Copy link
Contributor

Baviaan commented May 21, 2023

I reported in #1092 that the datetime is returned correctly only when supplying the timezone in the argument but not via settings, which is still the behaviour as of 1.1.7. As of 1.1.8, both options give the same result again, however the date is wrong. See an example below.

Note this is a different example than the one provided in #1092, the original example now works correctly on 1.1.8. This bug seems to occur when the time is already the next day in UTC.

Versions:

  • Ubuntu 22.04.1 LTS
  • Python 3.10.6
  • dateparser (1.1.8)
    • python-dateutil (2.8.2)
    • pytz (2022.6)
    • regex (2022.3.2)
    • tzlocal (4.2)

Minimum working example

#!/usr/bin/env python3
import dateparser
import datetime

parse_settings={
        'PREFER_DATES_FROM': 'future',
        'TO_TIMEZONE': 'etc/utc',
        'RETURN_AS_TIMEZONE_AWARE': False,
        'RELATIVE_BASE': datetime.datetime(2023, 5, 21, 15, 0)
        }

time = dateparser.parse('7pm EDT', settings=parse_settings)
print(time) # 2023-05-21 23:00:00
time = dateparser.parse('9pm EDT', settings=parse_settings)
print(time) # 2023-05-23 01:00:00

parse_settings['TIMEZONE'] = 'america/new_york'
time = dateparser.parse('7pm', settings=parse_settings)
print(time) # 2023-05-21 23:00:00
time = dateparser.parse('9pm', settings=parse_settings)
print(time) # 2023-05-23 01:00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant