feat: refactor the configuration view and implement the optional config for displaying timestamp in Log widget (#492)

This commit is contained in:
Fine0830
2025-08-20 15:30:01 +07:00
committed by GitHub
parent 7a8ee92bbb
commit a8c5ec8dd2
24 changed files with 267 additions and 357 deletions

View File

@@ -15,6 +15,11 @@
* limitations under the License.
*/
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);
export default function dateFormatStep(date: Date, step: string, monthDayDiff?: boolean): string {
const year = date.getFullYear();
const monthTemp = date.getMonth() + 1;
@@ -97,4 +102,10 @@ export const dateFormatTime = (date: Date, step: string): string => {
return "";
};
export const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => dayjs(new Date(date)).format(pattern);
export const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss", timezone?: string) => {
const dayjsInstance = dayjs(new Date(date));
if (timezone) {
return dayjsInstance.tz(timezone).format(pattern);
}
return dayjsInstance.format(pattern);
};