Natural language processing for date chooser

Our date picker and conversion is a powerful feature. I’d love to see us make it simpler to add a date/time to a post. A common way this is done is through natural language processing. Apps like Fantastical on iOS have used this for years for date input.

Instead of fiddling with the mouse to input a date, you could type in something like:

  • monday at 2pm which would output the date and time to your timezone
  • next friday at 10am NZST which outputs the date/time next friday in NZST
  • 11am which outputs today’s date at 11am
  • 8/9 to 8/13 which outputs a date range.

This could either replace the modal shown by clicking the calendar icon in the composer with a textbox (and an advanced button which shows the existing modal contents) or a separate modal launched by a keyboard shortcut.

9 Likes

This library might help with implementation: GitHub - wanasit/chrono: A natural language date parser in Javascript

That said I suspect it would be a challenge to get robust language support for this.

The current fully supported languages are en , ja , and fr ( de and pt are partially supported). Other languages from v1 ( nl and zh ) are under development.


Also, another UX pattern to consider is automatically replacing date strings in the body of a post with Discourse date/time objects. Sort of like one-boxing but for dates. E.g. if I type “next monday at 2pm” in my post, it automatically converts that to 2021-08-17T18:00:00Z.

5 Likes

I really like this idea!

3 Likes

I like this idea a lot, can you show me the UI mockup of how you see it working? That’s what is missing here.

There might not even need to be a UI. When a post is baked, NLP could process, come back to the client and confirm with a simple modal:

1 date was found. Would you like to convert to dynamic timestamps?
- tuesday at 2pm --> [discourse date]

Or, it could be simpler. Click the calendar icon, and instead of a date chooser, it’s a simple text box.

And similar to our invites modal, there could be a button for advanced controls which shows our existing date/time/timezone picker for more granular options.

I guess it is for @joffreyjaffeux to decide, not sure if that fits at all with the current UI we have? I am also not sure normal people want to type that much versus click especially on a smartphone?

It makes sense in google calendar because you can do this while typing in the name of the event, e.g. instead of typing

“Plumber”

you type

“Plumber 3pm - 5pm”

but that’s easy because I am on a device with a keyboard.

I actually find our modal tedious to use on both desktop and mobile, which is why I suggested this feature in the first place. It’s significantly faster to type today at 11:31am in a modal than to use the scrolly wheels or click around a large modal. The fact that many calendars do this already makes it less of a mental overhead for people to figure out.

1 Like

I agree on desktop. Do not agree on smartphone, because typing on smartphone is brutal. Maybe this could be a desktop only behavior?

1 Like

I’d be fine with that personally.

There is a lot of code in dates which actually already do this, we worked on this with @daniel

There are basically 3 ways to solve this:

  • a better modal
  • some !command
  • text parsing

The text parsing is great, but it doesn’t solve everything and also we have to make it work for all locales. But I do agree we could enable support of a small subset. It’s mostly already here, I would just have to finish/enable it.

5 Likes