wanasit / chrono

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

Expose ReferenceWithTimezone and ParsingComponents classes #526

Closed gcampax closed 1 year ago

gcampax commented 1 year ago

Hello! We have a use case where we are using chrono to parse dates of the format "$date for $duration" (eg. "8/10/2023 8am for 30 minutes". We use parse-duration to parse the duration part. In chrono 2.3.1, we then used a refiner to attach the duration as the end instant of the date with ParsingComponents.createRelativeFromRefInstant, using an internal import to get to the ParsingComponents class. The internal import no longer works in recent chrono though, due to the filtering done by package.json exports. Would it be possible to expose ParsingComponents as part of the public API, as well as the ReferenceWithTimezone class which used by createRelativeFromReference (successor of createRelativeFromRefInstant)? Thanks!

wanasit commented 1 year ago

Hello @gcampax. I'm sorry for not getting back to you sooner.

I have always intended to include ParsingComponents and ReferenceWithTimezone in the public interface (e.g. ParsingResult is already added). Sorry, I didn't notice we have removed them at some point.


Added them back in 99b2e9f8af17cb39be1777fc7e8a1335b0d257b6.

gcampax commented 1 year ago

That is great, thank you so much for fixing this so quickly, and thanks for the great library! :)