How to use the date-fns.isAfter 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 cozy / cozy.github.io / en / cozy-banks / src / ducks / balance / helpers.js View on Github external
DATE_FORMAT
    )
  )

  if (!from) {
    const earliestTransactionDate = getEarliestDate(
      ...Object.keys(transactionsByDate)
    )
    from = isDateValid(earliestTransactionDate) ? earliestTransactionDate : to
  }

  const balances = {}

  for (
    let day = to, balance = getAccountBalance(account);
    isDateAfter(day, from) || isDateEqual(day, from);
    day = subDays(day, 1)
  ) {
    const date = formatDate(day, DATE_FORMAT)
    const transactions = transactionsByDate[date]
    balance = transactions
      ? balance - sumBy(transactions, t => t.amount)
      : balance

    balances[date] = balance
  }

  return balances
}
github adarshpastakia / aurelia-ui-framework / src / forms / ui-date-range.ts View on Github external
protected weekChanged(week) {
    if (
      isWithinInterval(week, { start: this.minDate, end: this.maxDate }) ||
      isWithinInterval(endOfWeek(week), { start: this.minDate, end: this.maxDate })
    ) {
      this.start = isBefore(week, this.minDate) ? this.minDate : week;
      this.end = isAfter(endOfWeek(week), this.maxDate) ? this.maxDate : endOfWeek(week);
      this.startVm.currentMonth = startOfMonth(this.start);
      this.endVm.currentMonth = startOfMonth(this.end);
    }
  }
github adarshpastakia / aurelia-ui-framework / dist / forms / ui-date-range.js View on Github external
UIDateRange.prototype.weekChanged = function (week) {
        if (isWithinInterval(week, { start: this.minDate, end: this.maxDate }) ||
            isWithinInterval(endOfWeek(week), { start: this.minDate, end: this.maxDate })) {
            this.start = isBefore(week, this.minDate) ? this.minDate : week;
            this.end = isAfter(endOfWeek(week), this.maxDate) ? this.maxDate : endOfWeek(week);
            this.startVm.currentMonth = startOfMonth(this.start);
            this.endVm.currentMonth = startOfMonth(this.end);
        }
    };
    UIDateRange.prototype.startMonthChanged = function (month) {
github DanielYKPan / date-time-picker / src / picker.component.ts View on Github external
return false;
                }
            }
        }

        if (isValid && this.disabledDays && this.disabledDays.length) {
            let weekdayNum = getDay(value);
            isValid = this.disabledDays.indexOf(weekdayNum) === -1;
        }

        if (isValid && this.min) {
            isValid = isValid && !isBefore(value, this.min);
        }

        if (isValid && this.max) {
            isValid = isValid && !isAfter(value, this.max);
        }

        return isValid;
    }
github adarshpastakia / aurelia-ui-framework / src / calendar / ui-date.ts View on Github external
protected dateChanged(date): void {
    if (date && !this.ignoreChange) {
      this.ignoreChange = true;
      if (isBefore(date, this.minDate)) {
        date = toDate(this.minDate);
      }
      if (isAfter(date, this.maxDate)) {
        date = toDate(this.maxDate);
      }
      if (!this.isDateDisabled(date)) {
        this.date = toDate(date);
        this.time = toDate(this.date);
        this.currentYear = getYear(this.date);

        if (
          !isSameMonth(
            format(this.currentMonth, FORMAT_NO_TIMEZONE),
            format(this.date, FORMAT_NO_TIMEZONE)
          )
        ) {
          this.currentMonth = startOfMonth(this.date);
        }
      }
github matharumanpreet00 / react-daterange-picker / src / index.tsx View on Github external
const inHoverRange = (day: Date) => {
		return (startDate &&
			!endDate &&
			hoverDay &&
			isAfter(hoverDay, startDate) &&
			isWithinRange(day, startDate, hoverDay)) as boolean;
	};
github bullhorn / novo-elements / src / elements / date-picker / DatePicker.ts View on Github external
isDisabled(day, start, end) {
        return dateFns.isBefore(day, start) || dateFns.isAfter(day, end);
    }