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:
@@ -1,27 +1,26 @@
|
||||
const express = require("express");
|
||||
const { DateTime } = require("luxon");
|
||||
const Todo = require("../models/Todo");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Get day range in Korea Standard Time (UTC+9)
|
||||
// Korea Standard Time zone
|
||||
const KST_TIMEZONE = "Asia/Seoul";
|
||||
|
||||
// Get day range in Korea Standard Time (Asia/Seoul)
|
||||
const getDayRange = () => {
|
||||
const now = new Date();
|
||||
// Get current time in KST (UTC+9)
|
||||
const kstOffset = 9 * 60; // minutes
|
||||
const utcTime = now.getTime() + (now.getTimezoneOffset() * 60000);
|
||||
const kstTime = new Date(utcTime + (kstOffset * 60000));
|
||||
// Get current time in KST
|
||||
const nowKst = DateTime.now().setZone(KST_TIMEZONE);
|
||||
|
||||
// Start of day in KST
|
||||
const startKst = new Date(kstTime);
|
||||
startKst.setHours(0, 0, 0, 0);
|
||||
// Start of day in KST (00:00:00.000)
|
||||
const startOfDayKst = nowKst.startOf("day");
|
||||
|
||||
// End of day in KST
|
||||
const endKst = new Date(kstTime);
|
||||
endKst.setHours(23, 59, 59, 999);
|
||||
// End of day in KST (23:59:59.999)
|
||||
const endOfDayKst = nowKst.endOf("day");
|
||||
|
||||
// Convert back to UTC for MongoDB query
|
||||
const start = new Date(startKst.getTime() - (kstOffset * 60000));
|
||||
const end = new Date(endKst.getTime() - (kstOffset * 60000));
|
||||
// Convert to JavaScript Date objects (UTC) for MongoDB query
|
||||
const start = startOfDayKst.toJSDate();
|
||||
const end = endOfDayKst.toJSDate();
|
||||
|
||||
return { start, end };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user