From 575fadb48c07a86c8fb453184e0388d8dfcb79b1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 24 Dec 2021 19:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0dayjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/util.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/util.js b/src/common/util.js index c96b5e53..2b27480e 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -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 }