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

[enhancement] support human-friendly date parsing (e.g. "next monday at 3pm") #1281

Open
tgy opened this issue Jun 25, 2023 · 3 comments
Open

Comments

@tgy
Copy link
Contributor

tgy commented Jun 25, 2023

it would be great if we could create events with human-friendly readable date parsing such as:

  • next monday at 3pm
  • today at 2pm
  • in 1h
  • every tuesday at noon
  • once every 2 weeks on tuesday at noon
  • every first monday of the month

not all cases can be handled by dateparser but most i think (no need to run a big LLM on a 32GB memory GPU to parse this i think)

there's also recurrent which probably solves all cases!

recurrent.parse('every first monday of the month at 2pm until December')
'RRULE:BYDAY=1MO;BYHOUR=14;BYMINUTE=0;INTERVAL=1;FREQ=MONTHLY;UNTIL=20231201'
@geier
Copy link
Member

geier commented Jun 26, 2023

we had some discussion around that here #169

IIRC my biggest gripe with dateparser was that if you give a date without a year, it always interprets that with American "middle-endianness", but I might be an outlier here.

@tgy
Copy link
Contributor Author

tgy commented Jun 26, 2023

it's true if you set the locale to US, which makes sense, but if you set the locale to en-GB instead, here's what you get in comparison

import dateparser as dp
dp.parse('04/07 at 2pm')
# Out[6]: datetime.datetime(2023, 4, 7, 14, 0)

dp.parse('04/07 at 2pm', locales=['en-GB'])
# Out[7]: datetime.datetime(2023, 7, 4, 14, 0)

@geier
Copy link
Member

geier commented Jul 3, 2023

great to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants