devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
55 lines (53 loc) • 2.19 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/appointments/m_text_utils.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFormatType = exports.formatDates = exports.createFormattedDateText = 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
}
}
const createFormattedDateText = options => {
const {
startDate: startDate,
endDate: endDate,
allDay: allDay,
format: format
} = options;
const formatType = format || getFormatType(startDate, endDate, allDay);
return formatDates(startDate, endDate, formatType)
};
exports.createFormattedDateText = createFormattedDateText;
const getFormatType = (startDate, endDate, isAllDay, isDateAndTimeView) => {
if (isAllDay) {
return "DATE"
}
if (isDateAndTimeView && _date2.default.sameDate(startDate, endDate)) {
return "TIME"
}
return "DATETIME"
};
exports.getFormatType = getFormatType;
const formatDates = (startDate, endDate, formatType) => {
const isSameDate = startDate.getDate() === endDate.getDate();
switch (formatType) {
case "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 "TIME":
return `${_date.default.format(startDate,"shorttime")} - ${_date.default.format(endDate,"shorttime")}`;
case "DATE":
return `${_date.default.format(startDate,"monthandday")}${isSameDate?"":` - ${_date.default.format(endDate,"monthandday")}`}`
}
};
exports.formatDates = formatDates;