devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
63 lines (61 loc) • 2.57 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/appointments/m_text_utils.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/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFormatType = exports.formatDates = exports.createFormattedDateText = 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 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 DateFormatType.DATE
}
if (isDateAndTimeView && _date2.default.sameDate(startDate, endDate)) {
return DateFormatType.TIME
}
return DateFormatType.DATETIME
};
exports.getFormatType = getFormatType;
const formatDates = (startDate, endDate, formatType) => {
const isSameDate = startDate.getDate() === endDate.getDate();
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.formatDates = formatDates;