dateparser
dateparser copied to clipboard
Comparing output for `current_period` and `past` values of `PREFER_DATES_FROM` setting
I observed one interesting behavior where for some cases the current_period
and past
values of PREFER_DATES_FROM
return the same result but it's different for others. For example, suppose today is Thursday 23th, then
text = "Thursday"
print(dateparser.parse(text, settings={'PREFER_DATES_FROM': 'current_period'}))
>>> 2021-12-23 00:00:00
print(dateparser.parse(text, settings={'PREFER_DATES_FROM': 'past'}))
>>> 2021-12-16 00:00:00
This is the expected behavior, where for current_period
we get today's date (at the time of writing) i.e. 23rd, and for past
its last Thursday 16th.
Now for another case,
text = "Friday"
print(dateparser.parse(text, settings={'PREFER_DATES_FROM': 'current_period'}))
>>> 2021-12-17 00:00:00
print(dateparser.parse(text, settings={'PREFER_DATES_FROM': 'past'}))
>>> 2021-12-17 00:00:00
Here, the output is the same for both cases. But shouldn't the current_period
return the nearest Friday or at least the Friday of the ongoing week which will be 24th and not last Friday that is 17th?