From 53eaf232862fea86acf286809ddbe19652beebd6 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 8 May 2024 18:48:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=9B=A0=E6=97=B6=E5=8C=BA=E9=97=AE=E9=A2=98=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E5=B9=B4=E6=9C=88=E6=97=A5=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5=E8=81=94=E5=8A=A8?= =?UTF-8?q?=E4=B8=8D=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/utils/timeUitils.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/frontend/src/utils/timeUitils.js b/core/frontend/src/utils/timeUitils.js index 34e2f9a87f..84ee9d25f8 100644 --- a/core/frontend/src/utils/timeUitils.js +++ b/core/frontend/src/utils/timeUitils.js @@ -1,4 +1,5 @@ -export const getRange = (selectValue, timeGranularity) => { +export const getRange = (outerTimeValue, timeGranularity) => { + const selectValue = timeGranularity === 'y_M_d_H' ? outerTimeValue + ':' : outerTimeValue if (new Date(selectValue).toString() === 'Invalid Date') { return selectValue } @@ -57,7 +58,8 @@ const getMonthEnd = timestamp => { } const getDayEnd = timestamp => { - return [+new Date(timestamp), +new Date(timestamp) + 60 * 1000 * 60 * 24 - 1000] + const utcTime = getUtcTime(timestamp) + return [+utcTime, +utcTime + 60 * 1000 * 60 * 24 - 1000] } const getHourEnd = timestamp => { @@ -89,3 +91,12 @@ const getDayBegin = timestamp => { return +new Date(timestamp) } +const getUtcTime = timestamp => { + if (timestamp) { + const time = new Date(timestamp) + const utcDate = new Date(time.getUTCFullYear(), time.getUTCMonth(), time.getUTCDate(), time.getUTCHours(), time.getUTCMinutes(), time.getUTCSeconds()) + return utcDate + } else { + return timestamp + } +}