Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-domain into dev

This commit is contained in:
Xu Chang 2023-01-18 17:11:04 +08:00
commit bbce3c5f4b
3 changed files with 33 additions and 0 deletions

1
lib/utils/date.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare function excelStringToDate(str: string | number): number | undefined;

18
lib/utils/date.js Normal file
View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.excelStringToDate = void 0;
var tslib_1 = require("tslib");
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
function excelStringToDate(str) {
if (!str) {
return undefined;
}
if (typeof str === 'number') {
if (str < 100000) {
return (0, dayjs_1.default)((((str - 25569) * 24 - 8) * 3600) * 1000).valueOf(); // excel日期可能为1900-1-1至今的天数
}
return (0, dayjs_1.default)(str).valueOf();
}
return Date.parse(str);
}
exports.excelStringToDate = excelStringToDate;

14
src/utils/date.ts Normal file
View File

@ -0,0 +1,14 @@
import dayjs from 'dayjs';
export function excelStringToDate(str: string | number) {
if (!str) {
return undefined;
}
if (typeof str === 'number') {
if (str < 100000) {
return dayjs((((str - 25569) * 24 - 8) * 3600) * 1000).valueOf(); // excel日期可能为1900-1-1至今的天数
}
return dayjs(str).valueOf();
}
return Date.parse(str);
}