refactor: add timezone in

This commit is contained in:
moonrailgun 2023-10-30 00:14:59 +08:00
parent 4eefe8d9d7
commit 43e6f4ffe0
2 changed files with 7 additions and 2 deletions

View File

@ -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 };

View File

@ -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