I have found that the following MWE also seems to produce the same bug, even if PREFER_DATES_FROM is not set:
from datetime import datetime
from dateparser import parse
DATEPARSER_SETTINGS = {
'TIMEZONE': 'UTC',
'TO_TIMEZONE': 'UTC',
'RETURN_AS_TIMEZONE_AWARE': False,
'RELATIVE_BASE': datetime(2019, 8, 18, 3, 55, 1, 0)
}
dt = parse("9:57 PM MDT", settings=DATEPARSER_SETTINGS) # datetime(2019, 8, 19, 3, 57, 0)
expected = datetime(2019, 8, 18, 3, 57, 0)
assert dt == expected # fail: dt is a day later than expected
Note that RELATIVE_BASE is set to 9:55:01 PM MDT on 17 August, which is before the specified time of "9:57 PM MDT" in the parse input. The returned dt value is neither the nearest future or past instance of 9:57 PM MDT relative to the current time (RELATIVE_BASE).
I have found that the following MWE also seems to produce the same bug, even if PREFER_DATES_FROM is not set:
Note that RELATIVE_BASE is set to 9:55:01 PM MDT on 17 August, which is before the specified time of
"9:57 PM MDT"
in the parse input. The returneddt
value is neither the nearest future or past instance of 9:57 PM MDT relative to the current time (RELATIVE_BASE).Originally posted by @Laogeodritt in https://github.com/scrapinghub/dateparser/issues/403#issuecomment-524612341