chrono icon indicating copy to clipboard operation
chrono copied to clipboard

isOnlyDate() gives incorrect result when using Monday or some other weekday only

Open Pranoy1c opened this issue 2 years ago • 2 comments

I would expect the following to give false because there is no date but it gives true instead:

console.log("Result: "+chrono.parse('monday',null,{ forwardDate: true })[0].start?.isOnlyDate())

I think the problem is due to the current implementation of isOnlyDate() which doesn't check if the day, month is isCertain too. Also not sure if year needs to be certain too for it to be a isOnlyDate?:

isOnlyDate() {
        return !this.isCertain("hour") && !this.isCertain("minute") && !this.isCertain("second");
    }

Pranoy1c avatar Apr 21 '23 00:04 Pranoy1c

Hello @Pranoy1c.

The isOnlyDate() has not documented, but my intention was to check if the component describes a date but does not include time, hence "is only date". The implementation follows that meaning exactly.

Could I ask what is the use-case you have in mind for the function?

wanasit avatar Apr 22 '23 05:04 wanasit

@wanasit From what I understand, monday doesn't describe a date, it only specifies a day. It neither has date, nor time.

Pranoy1c avatar May 27 '23 20:05 Pranoy1c