fix: Asia/Seoul 타임존 지원을 위해 luxon 라이브러리 도입

- backend/routes/todos.js: 오늘의 할일 조회 시 KST 기준으로 날짜 계산
- backend/routes/schedules.js: 주간/월간 일정 조회 시 KST 기준으로 날짜 범위 계산
- backend/routes/bible.js: 오늘의 성경 구절 조회 시 KST 기준으로 날짜 계산
- flutter_app: Mock 데이터 사용 시 타임존 관련 주석 추가
This commit is contained in:
kihong.kim
2026-02-01 01:21:14 +09:00
parent bde2fc14c7
commit 32e67bfcc2
6 changed files with 54 additions and 33 deletions

View File

@@ -1,31 +1,35 @@
const express = require("express");
const { DateTime } = require("luxon");
const Schedule = require("../models/Schedule");
const router = express.Router();
const startOfWeek = (date = new Date()) => {
const copy = new Date(date);
const day = copy.getDay();
const diff = day === 0 ? -6 : 1 - day;
copy.setDate(copy.getDate() + diff);
copy.setHours(0, 0, 0, 0);
return copy;
// Korea Standard Time zone
const KST_TIMEZONE = "Asia/Seoul";
const startOfWeek = () => {
// Get current time in KST and find the start of the week (Monday)
const nowKst = DateTime.now().setZone(KST_TIMEZONE);
// Luxon uses 1 = Monday, 7 = Sunday
const startOfWeekKst = nowKst.startOf("week"); // Monday 00:00:00.000
return startOfWeekKst.toJSDate();
};
const endOfWeek = (date = new Date()) => {
const start = startOfWeek(date);
const end = new Date(start);
end.setDate(end.getDate() + 6);
end.setHours(23, 59, 59, 999);
return end;
const endOfWeek = () => {
// Get current time in KST and find the end of the week (Sunday)
const nowKst = DateTime.now().setZone(KST_TIMEZONE);
const endOfWeekKst = nowKst.endOf("week"); // Sunday 23:59:59.999
return endOfWeekKst.toJSDate();
};
const startOfMonth = (date = new Date()) => {
return new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0, 0);
const startOfMonth = () => {
const nowKst = DateTime.now().setZone(KST_TIMEZONE);
return nowKst.startOf("month").toJSDate();
};
const endOfMonth = (date = new Date()) => {
return new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59, 999);
const endOfMonth = () => {
const nowKst = DateTime.now().setZone(KST_TIMEZONE);
return nowKst.endOf("month").toJSDate();
};
router.get("/", async (req, res) => {