serokell / tzbot

Timezone bot for Slack
Mozilla Public License 2.0
7 stars 2 forks source link

Whitespace issue in parser #95

Open dcastro opened 1 year ago

dcastro commented 1 year ago

Clarification and motivation

At the moment, the parser only recognizes time references if:

This is implemented here:

https://github.com/serokell/tzbot/blob/0f58a5017d130bc5f450ecbcc449db2847a6111d/src/TzBot/Parser.hs#L274-L275

https://github.com/serokell/tzbot/blob/0f58a5017d130bc5f450ecbcc449db2847a6111d/src/TzBot/Parser.hs#L445

https://github.com/serokell/tzbot/blob/0f58a5017d130bc5f450ecbcc449db2847a6111d/src/TzBot/Parser.hs#L339-L340

The rationale is to avoid parsing things like "The product ID is AEH9AM" as "9AM".

However, there can be situations where a legitimate time reference is not actually preceded by a space:

>>> parseTimeRefs "How about Mike's suggestion (9am tomorrow)?"
[]

We should be able to parse these.

dcastro commented 1 year ago

Here's a real-world example: image

Notice how (5 pm MSK, 4 pm CET) was incorrectly interpreted as MSK, 4 pm. The 5 pm part was ignored because it was not preceded by a whitespace.

dcastro commented 1 year ago

Yes another real-world example:

it will be at 11 AM CEST (9 AM UTC+0, 12 PM MSK)

The bot parsed UTC+0, 12 PM