devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
62 lines (60 loc) • 2.69 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/appointments_new/utils/get_date_text.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDateTextFromTargetAppointment = exports.getDateText = exports.getDateFormatType = exports.DateFormatType = void 0;
var _date = _interopRequireDefault(require("../../../../common/core/localization/date"));
var _date2 = _interopRequireDefault(require("../../../../core/utils/date"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
var DateFormatType;
! function(DateFormatType) {
DateFormatType.DATETIME = "DATETIME";
DateFormatType.TIME = "TIME";
DateFormatType.DATE = "DATE"
}(DateFormatType || (exports.DateFormatType = DateFormatType = {}));
const getDateFormatType = (startDate, endDate, isAllDay, viewType) => {
if (isAllDay) {
return DateFormatType.DATE
}
if ("month" !== viewType && _date2.default.sameDate(startDate, endDate)) {
return DateFormatType.TIME
}
return DateFormatType.DATETIME
};
exports.getDateFormatType = getDateFormatType;
const getDateText = (startDate, endDate, formatType) => {
const isSameDate = _date2.default.sameDate(startDate, endDate);
switch (formatType) {
case DateFormatType.DATETIME:
return [_date.default.format(startDate, "monthandday"), " ", _date.default.format(startDate, "shorttime"), " - ", isSameDate ? "" : `${_date.default.format(endDate,"monthandday")} `, _date.default.format(endDate, "shorttime")].join("");
case DateFormatType.TIME:
return `${_date.default.format(startDate,"shorttime")} - ${_date.default.format(endDate,"shorttime")}`;
case DateFormatType.DATE:
return `${_date.default.format(startDate,"monthandday")}${isSameDate?"":` - ${_date.default.format(endDate,"monthandday")}`}`;
default:
return ""
}
};
exports.getDateText = getDateText;
const getDateTextFromTargetAppointment = (targetedAppointmentData, format, viewType) => {
const {
displayStartDate: startDate,
displayEndDate: endDate,
allDay: allDay
} = targetedAppointmentData;
const formatType = format ?? getDateFormatType(startDate, endDate, allDay, viewType);
return getDateText(startDate, endDate, formatType)
};
exports.getDateTextFromTargetAppointment = getDateTextFromTargetAppointment;