How to use the date-fns/add_days function in date-fns

To help you get started, we’ve selected a few date-fns 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 toptal / simple-react-calendar / src / calendar / month.tsx View on Github external
_getMaxDate() {
    const { rangeLimit, maxDate } = this.props
    // TODO: simplify with FC approach, remove state logic from child components
    //       this is passed from the parent component
    // @ts-ignore
    const calcEndDate = addDays(this._selectionStart, rangeLimit as number)

    if (maxDate) {
      const isCalcEndDayBefore = isBefore(calcEndDate, maxDate)

      return isCalcEndDayBefore ? calcEndDate : maxDate
    } else {
      return calcEndDate
    }
  }
github pluginjs / pluginjs / modules / time-table / src / main.js View on Github external
this.currentWeek = []

    // current day is sunday
    if (currentDayOfWeek === 0) {
      this.currentWeek.push(this.currentDay)
      for (let i = 1; i < 7; i++) {
        this.currentWeek.push(addDays(this.currentDay, i))
      }
    } else {
      // the days before currentDay in this week
      for (let i = currentDayOfWeek; i >= 0; i--) {
        this.currentWeek.push(subDays(this.currentDay, i))
      }
      // the days after currentDay in this week
      for (let i = 0; i < 6 - currentDayOfWeek; i++) {
        this.currentWeek.push(addDays(this.currentDay, i + 1))
      }
    }
  }
github webiny / webiny-js / examples / cloud-api / src / app / middleware.js View on Github external
                            expiresOn: args => addDays(new Date(), args.remember ? 30 : 1),
                            field: "loginSecurityUser"
github treebohotels / leaf-ui / src / Form / Form.story.js View on Github external
<select placeholder="Select a color" multiple="" label="Leaf color" name="leafColor">
        
        
          </select>
github vusion / cloud-ui / src / u-picker.vue / panel / u-panel-day.vue / index.js View on Github external
getAllDays(date) {
            this.dayRowArr = [];
            let start = startOfMonth(date);
            let end = lastDayOfMonth(date);
            start = addDays(startOfMonth(date), -getDay(start));
            end = addDays(lastDayOfMonth(date), 6 - getDay(end));
            let tempDate = start;
            while (!isAfter(tempDate, end)) {
                const rowArr = [];
                for (let i = 0; i &lt; 7; ++i) {
                    rowArr.push({
                        day: getDate(tempDate),
                        date: tempDate,
                        disabled: !inDateRange(tempDate, this.dateRange),
                    });
                    tempDate = addDays(tempDate, 1);
                }
                this.dayRowArr.push(rowArr);
            }
        },
        addMonth(monthGap) {
github vuikit / vuikit / packages / vuikit / src / components / datepicker / datepicker.vue View on Github external
maxPickableDate () {
      return isInteger(this.maxDate)
        ? addDays(Date.now(), this.maxDate)
        : this.maxDate
    },
    weekDays () {
github Talend / ui / packages / components / src / DateTimePickers / generator.js View on Github external
	const dates = new Array(7 * 6).fill(0).map((_, i) => addDays(firstDateOfCalendar, i));
github freiksenet / react-calendar / src / lib / components / Month.js View on Github external
const blockMonth = [];

  for (let i = 0; i &lt; daysInMonthWithFirstAndLastWeek + 1; i++) {
    const day = addDays(startOfMonthStartOfWeek, i);
    const dayKey = format(day, 'MM-D');
    const clsDay = cx('rc-Day', {
      'rc-Day--outside': isBefore(day, startOfMonth(date)) ||
        isAfter(day, endOfMonth(date)),
    });

    blockMonth.push(
      <div>
        {format(addDays(startOfMonthStartOfWeek, i), [dayFormat])}
      </div>
    );
  }

  return blockMonth;
}