tdesign-vue
Version:
86 lines (78 loc) • 2.66 kB
JavaScript
/**
* tdesign v1.11.2
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _common_js_datePicker_format = require('../_common/js/date-picker/format.js');
var isNil = require('../_chunks/dep-8b3c7277.js');
require('dayjs');
require('../_chunks/dep-27dd8cc6.js');
require('../_common/js/log/log.js');
require('../_chunks/dep-738b4f21.js');
require('../_chunks/dep-a4308f57.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-fcf0662d.js');
require('../_chunks/dep-e4278c54.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
function dateCorrection(partialIndex, preYear, preMonth, onlyYearSelect) {
var nextYear = preYear;
var nextMonth = preMonth;
if (partialIndex === 0) {
if (nextYear[1] <= nextYear[0]) {
if (onlyYearSelect) nextYear[1] = nextYear[0] + 1;else {
nextYear[1] = nextYear[0];
if (nextMonth[1] <= nextMonth[0]) {
nextMonth[1] = nextMonth[0] + 1;
if (nextMonth[1] === 12) {
nextMonth[1] = 0;
nextYear = [nextYear[0], nextYear[1] + 1];
}
}
}
}
}
if (partialIndex === 1) {
if (nextYear[0] >= nextYear[1]) {
if (onlyYearSelect) nextYear[0] = nextYear[1] - 1;else {
nextYear[0] = nextYear[1];
if (nextMonth[0] >= nextMonth[1]) {
nextMonth[0] = nextMonth[1] - 1;
if (nextMonth[0] === -1) {
nextMonth[0] = 11;
nextYear = [nextYear[0] - 1, nextYear[1]];
}
}
}
}
}
return {
nextYear: nextYear,
nextMonth: nextMonth
};
}
function parseToDateTime(value, format, times) {
if (isNil.isNil(value)) {
return null;
}
var dayjs = _common_js_datePicker_format.parseToDayjs(value, format);
if (times) {
var _times = _slicedToArray__default["default"](times, 4),
_times$ = _times[0],
hour = _times$ === void 0 ? 0 : _times$,
_times$2 = _times[1],
minute = _times$2 === void 0 ? 0 : _times$2,
_times$3 = _times[2],
second = _times$3 === void 0 ? 0 : _times$3,
_times$4 = _times[3],
millisecond = _times$4 === void 0 ? 0 : _times$4;
dayjs = dayjs.hour(hour).minute(minute).second(second).millisecond(millisecond);
}
return dayjs.toDate();
}
exports.dateCorrection = dateCorrection;
exports.parseToDateTime = parseToDateTime;
//# sourceMappingURL=utils.js.map