How to use the date-fns.isSameDay 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 anarock / pebble / packages / pebble-web / src / components / Calendar.tsx View on Github external
      datum => !!datum.timeStamp && isSameDay(date, datum.timeStamp)
    );
github bullhorn / novo-elements / projects / novo-elements / src / elements / date-picker / DatePicker.ts View on Github external
isStartFill(range, day, selected, selected2) {
    if (range && selected2 && selected) {
      return !dateFns.isSameDay(selected, selected2) && dateFns.isSameDay(day, selected) && dateFns.isBefore(day, selected2);
    }
    return false;
  }
github mattlewis92 / angular-calendar / demos / demo-modules / kitchen-sink / component.ts View on Github external
dayClicked({ date, events }: { date: Date; events: CalendarEvent[] }): void {
    if (isSameMonth(date, this.viewDate)) {
      this.viewDate = date;
      if (
        (isSameDay(this.viewDate, date) && this.activeDayIsOpen === true) ||
        events.length === 0
      ) {
        this.activeDayIsOpen = false;
      } else {
        this.activeDayIsOpen = true;
      }
    }
  }
github birkir / kvikmyndr-app / src / screens / coming-soon / ComingSoon.tsx View on Github external
renderSectionHeader({ section }: any) {
    const date = new Date(section.title);
    const today = new Date();
    const tomorrow = addDays(today, 1);
    let title = format(date, 'PPP', { locale: Store.settings.dateLocale })
      .replace(String((new Date()).getFullYear()), '')
      .trim()
      .replace(/\,$/, '');

    if (isSameDay(date, today)) title = 'Today';
    if (isSameDay(date, tomorrow)) title = 'Tomorrow';
    return (
      
    );
  }
github DanielYKPan / date-time-picker / src / picker.component.ts View on Github external
public isSelectedDay( date: Date ): boolean {
        if (this.isSingleSelection()) {
            return this.value && isSameDay(this.value, date);
        } else if (this.isRangeSelection() && this.value && this.value.length) {
            if (this.value[1]) {
                return (isSameDay(this.value[0], date) || isSameDay(this.value[1], date) ||
                    this.isDayBetween(this.value[0], this.value[1], date)) && this.isValidDay(date);
            } else {
                return isSameDay(this.value[0], date);
            }
        } else if (this.isMultiSelection() && this.value && this.value.length) {
            let selected;
            for (let d of this.value) {
                selected = isSameDay(d, date);
                if (selected) {
                    break;
                }
            }
            return selected;
        }
        return false;
    }
github kiwicom / margarita / packages / universal-components / src / RangeDatePicker / components / RenderDay.js View on Github external
render() {
    const {
      day,
      price,
      selectedDates,
      isRangePicker,
      isChoosingPastDatesEnabled,
      renderedCalendarRange,
    } = this.props;
    const isFieldEmpty = day == null;
    const isStartOfSelectedDates = day && isSameDay(selectedDates[0], day);
    const isEndOfSelectedDates = day && isSameDay(selectedDates[1], day);
    const isPossibleToChangeDateBackDirection =
      (day &&
        !this.isDayInPastActive(subDays(day, 1)) &&
        isBefore(renderedCalendarRange[0], day)) ||
      !isSameDay(selectedDates[0], selectedDates[1]);
    const isPossibleToChangeDateForwardDirection =
      (day && isBefore(day, renderedCalendarRange[1])) ||
      !isSameDay(selectedDates[0], selectedDates[1]);
    const isDaySelected =
      day &&
      isWithinInterval(day, {
        start: startOfDay(selectedDates[0]),
        end: endOfDay(selectedDates[1]),
      });
    const onArrowPress = onPress => (isRangePicker ? onPress : undefined);
github openmrs / openmrs-react-components / src / features / form / sagas.js View on Github external
function determineEncounterDatetime(submittedEncounterDatetime, existingEncounter, timestampNewEncounterIfCurrentDay) {
  if (!existingEncounter) {
    if (isToday(submittedEncounterDatetime) && timestampNewEncounterIfCurrentDay) {
      return format(new Date());
    }
    else {
      return format(submittedEncounterDatetime);
    }
  }
  else {
    if (isSameDay(existingEncounter.encounterDatetime, submittedEncounterDatetime)) {
      return format(existingEncounter.encounterDatetime);
    }
    else {
      return format(submittedEncounterDatetime);
    }
  }
}
github bullhorn / novo-elements / projects / novo-elements / src / elements / date-picker / DatePicker.ts View on Github external
isEndFill(range, day, selected, selected2) {
    if (range && selected2 && selected) {
      return !dateFns.isSameDay(selected, selected2) && dateFns.isSameDay(day, selected2) && dateFns.isAfter(day, selected);
    }
    return false;
  }
github matharumanpreet00 / react-daterange-picker / src / utils.ts View on Github external
export const isEndOfRange = ({ endDate }: DateRange, day: Date) =>
	(endDate && isSameDay(day, endDate)) as boolean;
github DanielYKPan / date-time-picker / src / picker.component.ts View on Github external
public isSelectedDay( date: Date ): boolean {
        if (this.isSingleSelection()) {
            return this.value && isSameDay(this.value, date);
        } else if (this.isRangeSelection() && this.value && this.value.length) {
            if (this.value[1]) {
                return (isSameDay(this.value[0], date) || isSameDay(this.value[1], date) ||
                    this.isDayBetween(this.value[0], this.value[1], date)) && this.isValidDay(date);
            } else {
                return isSameDay(this.value[0], date);
            }
        } else if (this.isMultiSelection() && this.value && this.value.length) {
            let selected;
            for (let d of this.value) {
                selected = isSameDay(d, date);
                if (selected) {
                    break;
                }
            }
            return selected;