Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
datum => !!datum.timeStamp && isSameDay(date, datum.timeStamp)
);
isStartFill(range, day, selected, selected2) {
if (range && selected2 && selected) {
return !dateFns.isSameDay(selected, selected2) && dateFns.isSameDay(day, selected) && dateFns.isBefore(day, selected2);
}
return false;
}
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;
}
}
}
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 (
);
}
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;
}
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);
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);
}
}
}
isEndFill(range, day, selected, selected2) {
if (range && selected2 && selected) {
return !dateFns.isSameDay(selected, selected2) && dateFns.isSameDay(day, selected2) && dateFns.isAfter(day, selected);
}
return false;
}
export const isEndOfRange = ({ endDate }: DateRange, day: Date) =>
(endDate && isSameDay(day, endDate)) as boolean;
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;