UNPKG

tav-ui

Version:
40 lines (35 loc) 1.4 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var dayjs_min = require('../../node_modules/.pnpm/dayjs@1.11.4/node_modules/dayjs/dayjs.min.js'); const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss"; const DATE_FORMAT = "YYYY-MM-DD"; function formatToDateTime(date, format = DATE_TIME_FORMAT) { return dayjs_min["default"](date).format(format); } function formatToDate(date, format = DATE_FORMAT) { return date ? dayjs_min["default"](date).format(format) : ""; } function formatToTimestamp(date, format = DATE_TIME_FORMAT) { return dayjs_min["default"](date, format).valueOf(); } function formatToExcelTime(date) { const timeStamp = formatToTimestamp(date); return (timeStamp / 1e3 + 8 * 3600) / 86400 + 70 * 365 + 19; } const dateUtil = dayjs_min["default"]; function getMomentFormatString(date, valueFormat = DATE_FORMAT) { if (dayjs_min["default"].isDayjs(date)) return date.format(valueFormat); if (typeof date === "string" && !(date.includes("T") || date.includes("Z"))) { return date; } else { return formatToDate(date, valueFormat); } } exports.dateUtil = dateUtil; exports.formatToDate = formatToDate; exports.formatToDateTime = formatToDateTime; exports.formatToExcelTime = formatToExcelTime; exports.formatToTimestamp = formatToTimestamp; exports.getMomentFormatString = getMomentFormatString; //# sourceMappingURL=dateUtil2.js.map