Refactor day type check function

This commit is contained in:
Hannu Lyytikainen 2018-07-26 17:59:48 +03:00
parent 4be615c352
commit 4e37f80482

View file

@ -107,16 +107,13 @@ const defaultProps = {
// Checks if time slot (propTypes.timeSlot) start time equals a day (moment)
const timeSlotEqualsDay = (timeSlot, day) => {
if (ensureTimeSlot(timeSlot).attributes.type === TIME_SLOT_DAY) {
// Time slots describe available dates by providing a start and
// an end date which is the following day. In the single date picker
// the start date is used to represent available dates.
const localStartDate = dateFromAPIToLocalNoon(timeSlot.attributes.start);
// Time slots describe available dates by providing a start and
// an end date which is the following day. In the single date picker
// the start date is used to represent available dates.
const localStartDate = dateFromAPIToLocalNoon(timeSlot.attributes.start);
return isSameDay(day, moment(localStartDate));
} else {
return false;
}
const isDay = ensureTimeSlot(timeSlot).attributes.type === TIME_SLOT_DAY;
return isDay && isSameDay(day, moment(localStartDate));
};
class DateInputComponent extends Component {