From f2369773a0090f3ac16bba9c18a594cfcdc54555 Mon Sep 17 00:00:00 2001 From: bcjang Date: Thu, 20 Feb 2025 11:15:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/common.js | 2 +- src/utils/date.js | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 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