From 8d18796d9bb9e6b75b7f762de8cdac746920914a Mon Sep 17 00:00:00 2001 From: kyuuseiryuu Date: Tue, 24 Mar 2026 17:58:23 +0900 Subject: [PATCH] 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. --- src/schedules/EventWatchSchedule.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/schedules/EventWatchSchedule.ts b/src/schedules/EventWatchSchedule.ts index c010942..1eeafef 100644 --- a/src/schedules/EventWatchSchedule.ts +++ b/src/schedules/EventWatchSchedule.ts @@ -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')); } } \ No newline at end of file