react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Filter dates

Open vmiimu opened this issue 9 years ago • 7 comments

Following example code for Filter dates to only display weekdays produces different results than example page.

<DatePicker
  selected={ this.state.startDate }
  onChange={ this.handleChange }
  filterDate={this.isWeekday}
  placeholderText="Select a weekday"
/>

Desired behavior: screenshot3

Current behavior: screenshot2

vmiimu avatar Apr 26 '17 09:04 vmiimu

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

mgrdevport avatar May 07 '17 21:05 mgrdevport

Closing due inactivity.

martijnrusschen avatar Jul 10 '17 08:07 martijnrusschen

It would be great if these were in the docs. It just asks for a function without any info on the function.

jamparke avatar Dec 14 '17 20:12 jamparke

@jamparke, contributions to improve the docs are welcome

rafeememon avatar Dec 14 '17 21:12 rafeememon

If others end up here, this is now:

const isWeekday = (date) => {
    const day = date.getDay()
    return day !== 0 && day !== 6
}

jamieallen59 avatar Jul 05 '19 10:07 jamieallen59

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

Hi Mgrdevport date.day() is working in your side?

yong-zong-dev avatar Jul 18 '19 14:07 yong-zong-dev

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

Hi Mgrdevport date.day() is working in your side?

try this

isWeekday = date => {
  const day = getDay(date)
  return day !== 0 && day !== 6
}

kevbarns avatar Aug 29 '19 16:08 kevbarns