tdesign-vue
Version:
88 lines (80 loc) • 2.74 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 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-1a76e9a7.js');
require('dayjs');
require('../_chunks/dep-c13dcbfd.js');
require('../_chunks/dep-fb824cb8.js');
require('../_common/js/log/log.js');
require('../_chunks/dep-a2217d56.js');
require('../_chunks/dep-3b2292ce.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-10fcb46d.js');
require('../_chunks/dep-ba7f5924.js');
require('../_chunks/dep-2bc87cc8.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