How to use the react-day-picker.DateUtils.addDayToRange function in react-day-picker

To help you get started, we’ve selected a few react-day-picker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moderntribe / the-events-calendar / src / modules / elements / month / element.js View on Github external
selectDay = ( day ) => {
		const { withRange } = this.props;
		let range = {};

		if ( withRange ) {
			range = DateUtils.addDayToRange( day, this.state );

			// if the range was unselected we fallback to the first available day
			if ( range.from === null && range.to === null ) {
				range.from = today;
				range.to = undefined;
			}

			if ( range.to && moment( range.to ).isSame( range.from ) ) {
				range.to = undefined;
			}
		} else {
			range.from = day;
			range.to = undefined;
		}

		this.setState( this.maybeUpdate( range ), () => {
github cedardevs / onestop / client / src / search / temporal / TemporalSearchComponent.jsx View on Github external
handleDayClick(e, day) {
    const range = DateUtils.addDayToRange(day, this.state)
    const self = this
    this.setState(range)
    // Convert to standard format for display
    _.forOwn(range, function(val, key){
      if (val) {
        let validDate = moment(val).format('L')
        self.setState({ [key + 'Temp']: validDate })
        // Update store
        self.formatAndUpdate(validDate, key)
      }
    })
  }
github Automattic / wp-calypso / client / components / date-range / index.js View on Github external
onSelectDate = date => {
		if ( ! this.isValidDate( date ) ) {
			return;
		}

		// DateUtils requires a range object with this shape
		const range = this.toDateRange( this.state.startDate, this.state.endDate );

		const rawDay = this.momentDateToJsDate( date );

		// Calculate the new Date range
		const newRange = DateUtils.addDayToRange( rawDay, range );

		// Update state to reflect new date range for
		// calendar and text inputs
		this.setState(
			previousState => {
				// Update to date or `null` which means "not date"
				const newStartDate = isNull( newRange.from )
					? NO_DATE_SELECTED_VALUE
					: this.nativeDateToMoment( newRange.from );
				const newEndDate = isNull( newRange.to )
					? NO_DATE_SELECTED_VALUE
					: this.nativeDateToMoment( newRange.to );

				// Update start/end state values
				let newState = {
					startDate: newStartDate,
github urbica / ui-kit / src / components / DataSelector / DataSelector.js View on Github external
handleDayClick(day) {
    const { from } = this.state;
    const { multiple, onChange } = this.props;
    if (multiple) {
      const range = DateUtils.addDayToRange(day, this.state);
      onChange(range);
      this.setState(range);
    } else if (from.getHours() !== 12) {
      const newDate = new Date(day.setHours(from.getHours()));
      onChange({ from: newDate });
      this.setState({ from: newDate });
    } else {
      onChange({ from: day });
      this.setState({ from: day });
    }
  }
github msindwan / zipkin-view / src / javascript / views / components / common / controls / DateTimeRangePicker.jsx View on Github external
handleDayClick(day, { disabled }) {
        if (!disabled) {
            const range = DateUtils.addDayToRange(day, this.state);
            this.setState(range);
        }
    }
github KissKissBankBank / kitten / assets / javascripts / kitten / components / date-picker / standalone-range / index.js View on Github external
const handleDayClick = day => {
    setDateRange(DateUtils.addDayToRange(day, dateRange))
  }
github sean-ww / react-redux-datatable / src / filters / CustomDateRangeFilter / CustomDateRangeFilter.jsx View on Github external
handleDayClick = day => {
    const range = DateUtils.addDayToRange(day, this.state);
    this.setState(range);
  };
github ayastreb / money-tracker / src / components / Transaction / Filter / Calendar.js View on Github external
handleDayClick = day => {
    const range = DateUtils.addDayToRange(day, this.state);
    this.setState(range);
  };
github fedspendingtransparency / data-act-broker-web-app / src / js / components / SharedComponents / CalendarRangeDatePicker.jsx View on Github external
handleDayClick(day) {
        const range = DateUtils.addDayToRange(day, this.state);
        this.setState(range);
    }