mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 17:05:10 +00:00
twelve hour time
This commit is contained in:
parent
8b2fe8d62d
commit
1f41bbed20
@ -97,7 +97,8 @@ export const appStore = defineStore({
|
|||||||
for (let i = 0; i <= endUnix - startUnix; i += interval) {
|
for (let i = 0; i <= endUnix - startUnix; i += interval) {
|
||||||
const temp: string = dateFormatTime(
|
const temp: string = dateFormatTime(
|
||||||
new Date(startUnix + i - utcSpace),
|
new Date(startUnix + i - utcSpace),
|
||||||
this.duration.step
|
this.duration.step,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
timeIntervals.push(temp);
|
timeIntervals.push(temp);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,11 @@ export default function dateFormatStep(
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dateFormatTime = (date: Date, step: string): string => {
|
export const dateFormatTime = (
|
||||||
|
date: Date,
|
||||||
|
step: string,
|
||||||
|
twentyFourHourTime: boolean
|
||||||
|
): string => {
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const monthTemp = date.getMonth() + 1;
|
const monthTemp = date.getMonth() + 1;
|
||||||
let month = `${monthTemp}`;
|
let month = `${monthTemp}`;
|
||||||
@ -83,11 +87,26 @@ export const dateFormatTime = (date: Date, step: string): string => {
|
|||||||
}
|
}
|
||||||
const hourTemp = date.getHours();
|
const hourTemp = date.getHours();
|
||||||
let hour = `${hourTemp}`;
|
let hour = `${hourTemp}`;
|
||||||
if (hourTemp < 10) {
|
let hourSuffix = "AM";
|
||||||
hour = `0${hourTemp}`;
|
if (twentyFourHourTime) {
|
||||||
|
if (hourTemp < 10) {
|
||||||
|
hour = `0${hourTemp}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hourTemp === 0) {
|
||||||
|
hour = "12";
|
||||||
|
} else if (hourTemp === 12) {
|
||||||
|
hour = "12";
|
||||||
|
hourSuffix = "PM";
|
||||||
|
} else if (hourTemp > 12) {
|
||||||
|
hour = `${hourTemp - 12}`;
|
||||||
|
hourSuffix = "PM";
|
||||||
|
} else {
|
||||||
|
hour = `${hourTemp}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (step === "HOUR") {
|
if (step === "HOUR") {
|
||||||
return `${month}-${day} ${hour}`;
|
return `${month}-${day} ${hour} ${hourSuffix}`;
|
||||||
}
|
}
|
||||||
const minuteTemp = date.getMinutes();
|
const minuteTemp = date.getMinutes();
|
||||||
let minute = `${minuteTemp}`;
|
let minute = `${minuteTemp}`;
|
||||||
@ -95,7 +114,7 @@ export const dateFormatTime = (date: Date, step: string): string => {
|
|||||||
minute = `0${minuteTemp}`;
|
minute = `0${minuteTemp}`;
|
||||||
}
|
}
|
||||||
if (step === "MINUTE") {
|
if (step === "MINUTE") {
|
||||||
return `${hour}:${minute}\n${month}-${day}`;
|
return `${hour}:${minute} ${hourSuffix}\n${month}-${day}`;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
@ -191,6 +191,10 @@ function getOption() {
|
|||||||
axisLabel: {
|
axisLabel: {
|
||||||
color: "#808080",
|
color: "#808080",
|
||||||
fontSize: "13",
|
fontSize: "13",
|
||||||
|
formatter: function (value) {
|
||||||
|
//todo: should only substr if date is current date
|
||||||
|
return (value as string).substring(0, value.indexOf("\n"));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
|
Loading…
Reference in New Issue
Block a user