chrono icon indicating copy to clipboard operation
chrono copied to clipboard

isTimeOnly() ignores year only

Open Novak-Peter opened this issue 3 years ago • 1 comments

When creating a custom parser for year only, and using this with ranges (like 2019-2021), second date will always be removed by ENMergeDateTimeRefiner / AbstractMergeDateTimeRefiner - due to the following expression:

https://github.com/wanasit/chrono/blob/606c28cf18a7789746c3ebd68a75a34531090169/src/common/refiners/AbstractMergeDateTimeRefiner.ts#L14

As it turns out, isOnlyTime ignores having year only:

https://github.com/wanasit/chrono/blob/606c28cf18a7789746c3ebd68a75a34531090169/src/results.ts#L108-L110 I would definitely add this here: && !this.isCertain("year")

If this is valid in your opinion, I can create a simple PR for this.

Novak-Peter avatar Apr 12 '22 07:04 Novak-Peter

If this is valid in your opinion, I can create a simple PR for this.

Your explanation make senses. Please feel free to submit a PR. Just make sure all current tests pass.

wanasit avatar Apr 16 '22 03:04 wanasit