wanasit / chrono

A natural language date parser in Javascript
MIT License
4.57k stars 341 forks source link

Property `isOnlyTime()` does not exist on type 'ParsedComponents' #573

Open bytrangle opened 1 week ago

bytrangle commented 1 week ago

For the ParsedComponents, I'm able to call isCertain(), but not isOnlyTime(). The only methods available according to Intellisense are get(), date(), get(), and tags(). I'm using the latest version, 2.7.7.

wanasit commented 6 days ago

The isOnlyTime() (and isOnlyDate()) belong to ParsingComponents (not ParsedComponents), an internal class/type for writing parsers and refiners. The method should be used with caution (e.g. calling isOnlyTime() on a relative date like "1 day ago" may not be correct).

I'm hesitating to expose those methods to the more visible ParsedComponents type. Could you explain your use case and the need for the methods to be included in the result type?

bytrangle commented 3 days ago

Thanks for getting back. The to-do app Super Productivity allows users to add start date for their to-dos using natural language, backed by chrono :). If a user only enters time with no date, how should you interpret it? For example: "Laundry 4pm". The start date for this task will depend on when the user creates the task:

Hope that makes sense, although I've started to see how using isOnlyTime() carelessly will open a can of bugs!