UNPKG

tdesign-react

Version:
75 lines (71 loc) 2.16 kB
/** * tdesign v1.15.1 * (c) 2025 tdesign * @license MIT */ import { _ as _slicedToArray } from '../_chunks/dep-48805ab8.js'; import { isNil } from 'lodash-es'; import { p as parseToDayjs } from '../_chunks/dep-9036728c.js'; import '../_chunks/dep-026a4c6b.js'; import 'dayjs'; import '../_chunks/dep-e29214cb.js'; import '../_chunks/dep-dbf3be07.js'; import '../_chunks/dep-f53c91cd.js'; import '../_chunks/dep-b908e1fe.js'; 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(value)) { return null; } var dayjs = parseToDayjs(value, format); if (times) { var _times = _slicedToArray(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(); } export { dateCorrection, parseToDateTime }; //# sourceMappingURL=utils.js.map