devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
50 lines (48 loc) • 2.17 kB
JavaScript
/**
* DevExtreme (cjs/ui/scheduler/appointments/textUtils.js)
* Version: 22.1.9
* Build date: Tue Apr 18 2023
*
* Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
exports.getFormatType = exports.formatDates = exports.createFormattedDateText = void 0;
var _date = _interopRequireDefault(require("../../../core/utils/date"));
var _date2 = _interopRequireDefault(require("../../../localization/date"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
var createFormattedDateText = function(options) {
var startDate = options.startDate,
endDate = options.endDate,
allDay = options.allDay,
format = options.format;
var formatType = format || getFormatType(startDate, endDate, allDay);
return formatDates(startDate, endDate, formatType)
};
exports.createFormattedDateText = createFormattedDateText;
var getFormatType = function(startDate, endDate, isAllDay, isDateAndTimeView) {
if (isAllDay) {
return "DATE"
}
if (isDateAndTimeView && _date.default.sameDate(startDate, endDate)) {
return "TIME"
}
return "DATETIME"
};
exports.getFormatType = getFormatType;
var formatDates = function(startDate, endDate, formatType) {
var isSameDate = startDate.getDate() === endDate.getDate();
switch (formatType) {
case "DATETIME":
return [_date2.default.format(startDate, "monthandday"), " ", _date2.default.format(startDate, "shorttime"), " - ", isSameDate ? "" : _date2.default.format(endDate, "monthandday") + " ", _date2.default.format(endDate, "shorttime")].join("");
case "TIME":
return "".concat(_date2.default.format(startDate, "shorttime"), " - ").concat(_date2.default.format(endDate, "shorttime"));
case "DATE":
return "".concat(_date2.default.format(startDate, "monthandday")).concat(isSameDate ? "" : " - " + _date2.default.format(endDate, "monthandday"))
}
};
exports.formatDates = formatDates;