diff --git a/src/utils/common.js b/src/utils/common.js index 2ee3ff5..9c8c157 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -13,7 +13,7 @@ export const convertKTC = (dt, nation = true) => { timeZone: 'Asia/Seoul', }; - return nation ? date.toLocaleString('ko-KR', options) + " KTC" : date.toLocaleString('ko-KR', options); + return nation ? date.toLocaleString('ko-KR', options) + " KST" : date.toLocaleString('ko-KR', options); } export const convertKTCDate = (dt) => { diff --git a/src/utils/date.js b/src/utils/date.js index 2fa5926..d751017 100644 --- a/src/utils/date.js +++ b/src/utils/date.js @@ -1,4 +1,4 @@ -import { ONE_MINUTE_MS } from '../assets/data/adminConstants'; +import { ONE_MINUTE_MS, ONE_MINUTE_SECOND } from '../assets/data/adminConstants'; export const convertStartDateToISO = (date) => { if (!date) return null; @@ -31,6 +31,30 @@ export const getTimeOnly = (dateString) => { }); }; +export const getDateOnly = (dateString) => { + const date = new Date(dateString); + return date.toISOString().slice(0, 10); +} + export const msToMinutes = (ms) => { return ms / ONE_MINUTE_MS; +} + +export const secondToMinutes = (second) => { + return second / ONE_MINUTE_SECOND; +} + +export const isValidDayRange = (start_dt, end_dt) => { + const startDate = new Date(start_dt); + const endDate = new Date(end_dt); + + // 시간을 00:00:00으로 설정하여 날짜만 비교 + const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()); + const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()); + + const diffTime = endDateOnly.getTime() - startDateOnly.getTime(); + + const oneDay = 24 * 60 * 60 * 1000; + + return diffTime >= oneDay; } \ No newline at end of file