refactor(schedules): use Asia/Tokyo timezone for event logs
- Import and extend 'dayjs' with 'utc' and 'timezone' plugins. - Update logging in 'watchEvents' and 'start' methods to explicitly format dates in 'Asia/Tokyo' timezone instead of default system time. - This ensures consistent timestamp representation across different deployment environments regardless of the local server timezone.
This commit is contained in:
parent
0a1c424798
commit
8d18796d9b
@ -7,6 +7,11 @@ import { sendNotification } from '../utils/firebase-admin';
|
||||
import { prisma } from '../prisma/db';
|
||||
import type { Schedule } from './schedule';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
export class EventWatchSchedule implements Schedule {
|
||||
|
||||
@ -15,7 +20,7 @@ export class EventWatchSchedule implements Schedule {
|
||||
constructor() {}
|
||||
|
||||
async watchEvents() {
|
||||
console.debug('nextStartTime: %s', dayjs(this.#job?.nextInvocation()).format('YYYY-MM-DD HH:mm:ss'));
|
||||
console.debug('nextStartTime: %s', dayjs.tz(this.#job?.nextInvocation(), 'Asia/Tokyo').format('YYYY-MM-DD HH:mm:ss'));
|
||||
const events = await EventSubscribeService.getAllEvents();
|
||||
events.forEach((e) => this.diffEvent(e));
|
||||
}
|
||||
@ -66,6 +71,6 @@ export class EventWatchSchedule implements Schedule {
|
||||
hour: new nodeSchedule.Range(7, 23),
|
||||
}, () => this.watchEvents());
|
||||
this.#job = job;
|
||||
console.debug('Start schedule: %s, next run at %s', job.name, dayjs(job.nextInvocation()).format('YYYY-MM-DD HH:mm:ss'));
|
||||
console.debug('Start schedule: %s, next run at %s', job.name, dayjs.tz(job.nextInvocation(), 'Asia/Tokyo').format('YYYY-MM-DD HH:mm:ss'));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user