correctFormat
seems to have a few problems inferring date from incomplete inputs.
This is how the date column is set up: (React)
correctFormat={true}
columns={[
{
data: 'date',
type: 'date',
dateFormat: 'DD/MM/YYYY',
}
...
The expected behaviour is that any input of the type D/M
e.g. 15/2
should be converted to DD/MM/YYYY
for the current year.
I think the problem is best described by a series of examples of what does/doesn’t work:
// input => result
// if both DD < 13 && MM < 13, it works
1/2/21 => 01/02/2021 // works
1/2 => 01/02/2021 // works
1/2/2021 => 01/02/2021 // works
15/2/21 => 15/2/21 // doesn't work, red warning, expected 15/02/2021
15/2 => 15/2 // doesn't work, red warning, expected 15/02/2021
2/15/21 => 15/02/2021 // works, but irrelevant for my usecase
02/15/2021 => 15/02/2021 // works, but irrelevant for my usecase
2/15 => 15/02/2001 // doesn't work, but irrelevant for my usecase
// typing out the full year also has mixed results
2/15/2021 => 15/02/2021 // works, but irrelevant for my usecase
15/2/2021 => 15/2/2021 // doesn't work, expected 15/02/2021
1/2/2021 => 01/02/2021 // works
// finally, typing the date verbatim works
15/02/2021 => 15/02/2021 // works
In other words, it seems like the parser always interpret the inputs as M/D
. From the short time I worked with moment
I know this is a tough one to solve, but at the very least correctFormat
should consider what dateFormat
I’ve set. E.g. It should be able to read dateFormat: DD/MM/YYYY
and infer that I’m expected to input DD/MM
or D/M
or D/M/YY
etc.