From 8e18075be41024cf1e8bfd27180ead1f3c65d9a5 Mon Sep 17 00:00:00 2001 From: bb_pan Date: Sun, 14 Sep 2025 11:27:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/bonus.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/utils/bonus.js b/src/utils/bonus.js index bad49a84..8419a1ec 100644 --- a/src/utils/bonus.js +++ b/src/utils/bonus.js @@ -286,4 +286,20 @@ export function toChineseAmount(n) { export function validateIdCard(idCard) { const idCardRegex = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/ return idCardRegex.test(idCard) -} \ No newline at end of file +} + +export function formatDate(date) { + const y = date.getFullYear() + const m = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + return `${y}-${m}-${day}` +} +export function formatTime(date) { + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + const hours = String(date.getHours()).padStart(2, '0') + const minutes = String(date.getMinutes()).padStart(2, '0') + const seconds = String(date.getSeconds()).padStart(2, '0') + return `${year}${month}${day}_${hours}${minutes}${seconds}` +}