pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.54k stars 198 forks source link

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

Open tgy opened 1 year ago

tgy commented 1 year ago

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

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 commented 1 year ago

we had some discussion around that here https://github.com/pimutils/khal/issues/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 commented 1 year ago

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 commented 1 year ago

great to hear!