From 43e6f4ffe092cc71be17e95cf9c02bc3711713a2 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 30 Oct 2023 00:14:59 +0800 Subject: [PATCH] refactor: add timezone in --- src/client/utils/date.ts | 3 +++ src/server/model/monitor/index.ts | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/utils/date.ts b/src/client/utils/date.ts index 7340544..66a5e97 100644 --- a/src/client/utils/date.ts +++ b/src/client/utils/date.ts @@ -1,9 +1,12 @@ import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; +import advancedFormat from 'dayjs/plugin/advancedFormat'; import type { DateUnit } from '../../shared'; + dayjs.extend(utc); dayjs.extend(timezone); +dayjs.extend(advancedFormat); export type { DateUnit }; diff --git a/src/server/model/monitor/index.ts b/src/server/model/monitor/index.ts index fccd347..1151186 100644 --- a/src/server/model/monitor/index.ts +++ b/src/server/model/monitor/index.ts @@ -165,17 +165,19 @@ class MonitorRunner { await this.notify( `[${monitor.name}] 🔴 Down`, `[${monitor.name}] 🔴 Down\nTime: ${dayjs().format( - 'YYYY-MM-DD HH:mm:ss' + 'YYYY-MM-DD HH:mm:ss (z)' )}` ); + currentStatus = 'DOWN'; } else if (value > 0 && currentStatus === 'DOWN') { await this.createEvent('UP', `Monitor [${monitor.name}] has been up`); await this.notify( `[${monitor.name}] ✅ Up`, `[${monitor.name}] ✅ Up\nTime: ${dayjs().format( - 'YYYY-MM-DD HH:mm:ss' + 'YYYY-MM-DD HH:mm:ss (z)' )}` ); + currentStatus = 'UP'; } // insert into data