增加dayjs

This commit is contained in:
aixianling
2021-12-24 19:11:19 +08:00
parent 4ea78acc5c
commit 575fadb48c

View File

@@ -1,5 +1,5 @@
import dict from "./dict";
import $moment from './monent';
import dayjs from './monent';
const confirm = (content, title, config) => {
let ops = {content}
@@ -26,11 +26,11 @@ const confirm = (content, title, config) => {
const calcAge = (code) => {
let birthday
if (typeof code == 'string' && code.length == 18) {
birthday = $moment(code.substring(6, 14), 'YYYYMMDD')
birthday = dayjs(code.substring(6, 14), 'YYYYMMDD')
} else if (typeof code == 'object') {
birthday = code
}
return Math.ceil($moment().year() - $moment(birthday).year())
return Math.ceil(dayjs().year() - dayjs(birthday).year())
}
export default {
@@ -38,7 +38,7 @@ export default {
confirm,
calcAge,
dateFormat: (time, format) => {
return $moment(time).format(format || 'YYYY-MM-DD').replace("Invalid Date", "")
return dayjs(time).format(format || 'YYYY-MM-DD').replace("Invalid Date", "")
},
formatName: (name) => {
return Array.from(name)?.slice(-2)?.toString() || "";
@@ -73,5 +73,6 @@ export default {
let hex = r << 16 | g << 8 | b;
return "#" + hex.toString(16);
}
}
},
dayjs
}