neilgupta / Sherlock

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

Relative dates #23

Closed ncammarata closed 6 years ago

ncammarata commented 6 years ago

Hi Neil,

Awesome work so far! What do you think about having days/weeks/months automatically have an end? For instance, yesterday started at midnight and ended at midnight. I'm doing basic NLP for event filtering, and it would be helpful to have explicit starts and ends when available.

Curious to hear your thoughts!

neilgupta commented 6 years ago

You could easily add this functionality for your app via Watson's postprocessor. Something like the following should do what you need:

postprocess: function(Sherlocked) {
    if (Sherlocked.isAllDay) {
        if (!Sherlocked.endDate) {
            Sherlocked.endDate = new Date(Sherlocked.startDate);
        }
        Sherlocked.endDate.setHours(23,59,59);
    }
    return Sherlocked;
}
neilgupta commented 6 years ago

Closing this issue since I think Watson solves the problem sufficiently. Let me know if you disagree!

ncammarata commented 6 years ago

Thanks @neilgupta!