pimutils / khal

:calendar: CLI calendar application

Home Page:https://lostpackets.de/khal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tgy opened this issue · comments

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'

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.

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)

great to hear!