react-day-picker icon indicating copy to clipboard operation
react-day-picker copied to clipboard

formatDate moment integration bug

Open gatispriede opened this issue 8 years ago • 1 comments

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)
    }}
/>

gatispriede avatar Nov 08 '18 07:11 gatispriede

Also affects from type same way, data input = normal Date object

gatispriede avatar Nov 08 '18 07:11 gatispriede