neilgupta / Sherlock

Natural-language event parser for Javascript
https://sherlock.neil.gg
MIT License
538 stars 32 forks source link

24 Hour time #14

Closed danjford closed 8 years ago

danjford commented 8 years ago

If you try using a 24 hour time then the time gets set to 00:00:00.

I.e. this works Meeting today at 3, but this doesn't Meeting today at 15

danjford commented 8 years ago

Possible fix, change patterns.explicitTime from:

/(?:@ ?)?\b(?:at |from )?(1[0-2]|[1-9])(?::?([0-5]\d))? ?([ap]\.?m?\.?)?(?:o'clock)?\b/

To:

/(?:@ ?)?\b(?:at |from )?([0-2]?[1-9])(?::?([0-5]\d))? ?([ap]\.?m?\.?)?(?:o'clock)?\b/

neilgupta commented 8 years ago

This is a reasonable solution, but it breaks some of the tests. In particular, supporting "15" like this seems to introduce bugs in the ambiguous date parsing code. "Meeting today at 1500" works as expected, but the short form confuses Sherlock. I agree this should be fixed, but it will likely require a more complex solution or trade off in accuracy for more ambiguous statements.