react-day-picker
react-day-picker copied to clipboard
formatDate moment integration bug
Hi there,
formatDate from 'react-day-picker/moment' has a bug parsing years, when you use 2 months, together with input field, changing to field to next year , and then re-opening shows previous year, took me a while to figure out that that's the function that causes issues.
Sample code with faulty peace commented out:
const today = moment();
<DayPickerInput
ref={el => (this.to = el)}
value={to}
placeholder="To"
format="DD MMM"
formatDate={formatDate}
// parseDate={parseDate}
dayPickerProps={{
initialMonth: today._id,
selectedDays: [{from, to}],
disabledDays: {before: from},
fromMonth: today._d,
modifiers: {start: from, end: to},
month: to,
numberOfMonths: 2,
}}
onDayChange={value => {
this.handleToChange(value)
}}
/>
Also affects from type same way, data input = normal Date object