날짜 처리

This commit is contained in:
2025-02-20 11:15:20 +09:00
parent c375bc1164
commit f2369773a0
2 changed files with 26 additions and 2 deletions

View File

@@ -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) => {

View File

@@ -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;
}