Open kamaca opened 2 years ago
@kamaca for next monday , maybe you can use settings={'PREFER_DATES_FROM': 'future'})
, this would give you the future monday.
from dateparser.search import search_dates
>>> search_dates("today")
[('today', datetime.datetime(2022, 1, 22, 17, 33, 59, 613985))]
>>> search_dates("next monday",settings={'PREFER_DATES_FROM': 'future'})
[('monday', datetime.datetime(2022, 1, 24, 0, 0))]
@atharmohammad Thank you for the suggestion🙏. It works great as I will only need future dates 🙌
One additional thing I noticed - when "next + day of the week" is supplied with something like 2am it outputs next month (and again, when using same AM time with :minutes it works fine). This is not a dealbreaker as I will use AM time with minutes, but just in case my output for reference is below:
>>> search.search_dates("next monday 2pm",settings={'PREFER_DATES_FROM': 'future'})
[('monday 2pm', datetime.datetime(2022, 1, 31, 14, 0))]
>>> search.search_dates("next monday 2am",settings={'PREFER_DATES_FROM': 'future'})
[('monday 2am', datetime.datetime(2022, 2, 24, 0, 0))]
>>> search.search_dates("next tuesday 2pm",settings={'PREFER_DATES_FROM': 'future'})
[('tuesday 2pm', datetime.datetime(2022, 1, 25, 14, 0))]
>>> search.search_dates("next tuesday 2am",settings={'PREFER_DATES_FROM': 'future'})
[('tuesday 2am', datetime.datetime(2022, 2, 24, 0, 0))]
>>> search.search_dates("next monday 2:00am",settings={'PREFER_DATES_FROM': 'future'})
[('monday 2:00am', datetime.datetime(2022, 1, 31, 2, 0))]
>>> search.search_dates("next tuesday 2:00am",settings={'PREFER_DATES_FROM': 'future'})
[('tuesday 2:00am', datetime.datetime(2022, 1, 25, 2, 0))]
Hi all, I've noticed that when I use "am" in search_dates it doesn't work, but when supplied with :minutes it works fine (below is the output of installation and usage with some comments). "pm" seems to work ok. Also having issue when searching for example "next monday" - it returns past monday. Maybe it's just me, any advise is appreciated.
Thank you for this amazing module 🙏 it's such a timesaver and sorry if I missed similar issue from earlier.