diff --git a/src/utils/appUtils.js b/src/utils/appUtils.js index 6f652db9..ce708ed6 100644 --- a/src/utils/appUtils.js +++ b/src/utils/appUtils.js @@ -69,12 +69,15 @@ export const normalizeAllowedContentTypes = (allowedContentType) => { return allowedContentType.split(","); return []; }; - export function localToUtc(localDateString) { - if (!localDateString || localDateString.trim() === "") return null; + if (!localDateString || typeof localDateString !== "string") return null; - const [day, month, year] = localDateString.split("-"); - const date = new Date(`${year}-${month}-${day}T00:00:00`); + const [year, month, day] = localDateString.trim().split("-"); + + if (!year || !month || !day) return null; + + + const date = new Date(Number(year), Number(month) - 1, Number(day), 0, 0, 0); return isNaN(date.getTime()) ? null : date.toISOString(); }