chrono icon indicating copy to clipboard operation
chrono copied to clipboard

No support for `today`/`tomorrow` in chrono.en.GB?

Open trafium opened this issue 3 years ago • 2 comments

It is not clear to me from README whether en.GB parser is supposed to be fully featured or not.

My use case is that I want to parse dates in english, but I never want it to interpret string like 01.10.2021 (with different separators) as MDY, but rather as DMY. But GB parser seems not to be working with strings like today/tomorrow (but seems to be working just fine with things like next friday so that makes me think it might be a bug).

console.log(chrono.parseDate('today', undefined, { forwardDate: true })); // => 2021-09-30T14:39:50.798Z
console.log(chrono.en.GB.parseDate('today', undefined, { forwardDate: true })); // => null

console.log(chrono.parseDate('tomorrow', undefined, { forwardDate: true })); // => 2021-10-01T14:39:50.901Z
console.log(chrono.en.GB.parseDate('tomorrow', undefined, { forwardDate: true })); // => null

console.log(chrono.parseDate('next friday', undefined, { forwardDate: true })); // => 2021-10-08T09:00:00.000Z
console.log(chrono.en.GB.parseDate('next friday', undefined, { forwardDate: true })); // => 2021-10-08T09:00:00.000Z

trafium avatar Sep 30 '21 14:09 trafium

Yeah, I experienced the same thing, still not fixed in the latest version 2.7.0.

thongquach avatar Oct 09 '23 08:10 thongquach

Encountered this as well. Workaround for me was to use the default chrono.parseDate as a fallback, whenever chrono.en.GB returned null.

Andonvr avatar Jan 09 '24 09:01 Andonvr