forked from github/dataease
fix(仪表板): 解决因时区问题导致的年月日格式的时间字段联动不准确问题
This commit is contained in:
parent
fe740e3cf8
commit
53eaf23286
@ -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') {
|
if (new Date(selectValue).toString() === 'Invalid Date') {
|
||||||
return selectValue
|
return selectValue
|
||||||
}
|
}
|
||||||
@ -57,7 +58,8 @@ const getMonthEnd = timestamp => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getDayEnd = 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 => {
|
const getHourEnd = timestamp => {
|
||||||
@ -89,3 +91,12 @@ const getDayBegin = timestamp => {
|
|||||||
return +new Date(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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user