From bfe92571844ec1f2aefb999871971c51c1188909 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Mon, 12 May 2025 11:32:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6):=20iP?= =?UTF-8?q?hone=20=E6=89=8B=E6=9C=BA=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=9F=A5=E8=AF=A2=E6=A1=86=E7=9A=84=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20#16011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-component/v-query/time-format.ts | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/core/core-frontend/src/custom-component/v-query/time-format.ts b/core/core-frontend/src/custom-component/v-query/time-format.ts index e194056f2f..7453e0bb78 100644 --- a/core/core-frontend/src/custom-component/v-query/time-format.ts +++ b/core/core-frontend/src/custom-component/v-query/time-format.ts @@ -1,20 +1,19 @@ import type { ManipulateType } from 'dayjs' import dayjs from 'dayjs' function getThisYear() { - return new Date(`${new Date().getFullYear()}/1`) + return new Date(dayjs().startOf('year').format('YYYY/MM/DD HH:mm:ss')) } function getLastYear() { - return new Date(`${new Date().getFullYear() - 1}/1`) + return new Date(dayjs().subtract(1, 'year').startOf('year').format('YYYY/MM/DD HH:mm:ss')) } function getNextYear() { - return new Date(`${new Date().getFullYear() + 1}/1`) + return new Date(dayjs().add(1, 'year').startOf('year').format('YYYY/MM/DD HH:mm:ss')) } function getThisMonth() { - const date = new Date() - return new Date(`${date.getFullYear()}/${date.getMonth() + 1}`) + return new Date(dayjs().startOf('month').format('YYYY/MM/DD HH:mm:ss')) } function getLastStart(val = 'month' as ManipulateType) { @@ -26,23 +25,19 @@ function getLastMonth() { } function getNextMonth() { - const date = getCustomTime(1, 'month', 'month', 'b') - return new Date(`${date.getFullYear()}/${date.getMonth() + 1}`) + return new Date(dayjs().add(1, 'month').startOf('month').format('YYYY/MM/DD HH:mm:ss')) } function getToday() { - const date = new Date() - return new Date(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`) + return new Date(dayjs().startOf('day').format('YYYY/MM/DD HH:mm:ss')) } function getYesterday() { - const date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000) - return new Date(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`) + return new Date(dayjs().subtract(1, 'day').startOf('day').format('YYYY/MM/DD HH:mm:ss')) } function getMonthBeginning() { - const date = new Date() - return new Date(`${date.getFullYear()}/${date.getMonth() + 1}/1`) + return new Date(dayjs().startOf('month').format('YYYY/MM/DD HH:mm:ss')) } function getMonthEnd() { @@ -50,8 +45,7 @@ function getMonthEnd() { } function getYearBeginning() { - const date = new Date() - return new Date(`${date.getFullYear()}/1/1`) + return new Date(dayjs().startOf('year').format('YYYY/MM/DD HH:mm:ss')) } function getYearMonthRange(result, sort) {