devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
34 lines (33 loc) • 1.54 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/r1/utils/exclude_from_recurrence.js)
* Version: 25.2.5
* Build date: Fri Feb 20 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import dateSerialization from "../../../../core/utils/date_serialization";
import {
AppointmentAdapter
} from "../../utils/appointment_adapter/appointment_adapter";
const FULL_DATE_FORMAT = "yyyyMMddTHHmmss";
const UTC_FULL_DATE_FORMAT = `${FULL_DATE_FORMAT}Z`;
const getSerializedDate = (date, startDate, isAllDay) => {
if (isAllDay) {
date.setHours(startDate.getHours(), startDate.getMinutes(), startDate.getSeconds(), startDate.getMilliseconds())
}
return dateSerialization.serializeDate(date, UTC_FULL_DATE_FORMAT)
};
const createRecurrenceException = (appointmentAdapter, exceptionDate) => {
const result = [];
if (appointmentAdapter.recurrenceException) {
result.push(appointmentAdapter.recurrenceException)
}
result.push(getSerializedDate(exceptionDate, appointmentAdapter.startDate, appointmentAdapter.allDay));
return result.join()
};
export const excludeFromRecurrence = (appointment, exceptionDate, dataAccessors) => {
const appointmentAdapter = new AppointmentAdapter(Object.assign({}, appointment), dataAccessors);
appointmentAdapter.recurrenceException = createRecurrenceException(appointmentAdapter, exceptionDate);
return appointmentAdapter
};