update date utility for localtoUtc fn
This commit is contained in:
parent
fdbd81c5e7
commit
d1c72291a3
@ -69,12 +69,15 @@ export const normalizeAllowedContentTypes = (allowedContentType) => {
|
|||||||
return allowedContentType.split(",");
|
return allowedContentType.split(",");
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function localToUtc(localDateString) {
|
export function localToUtc(localDateString) {
|
||||||
if (!localDateString || localDateString.trim() === "") return null;
|
if (!localDateString || typeof localDateString !== "string") return null;
|
||||||
|
|
||||||
const [day, month, year] = localDateString.split("-");
|
const [year, month, day] = localDateString.trim().split("-");
|
||||||
const date = new Date(`${year}-${month}-${day}T00:00:00`);
|
|
||||||
|
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();
|
return isNaN(date.getTime()) ? null : date.toISOString();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user