22 lines
648 B
TypeScript
22 lines
648 B
TypeScript
/** 촬영일시 원본은 유지하고 등록·수정 화면 표출값만 YYYY-MM-DD로 정규화한다. */
|
|
export const formatDredgingCapturedDate = (
|
|
value: string | null | undefined,
|
|
) => {
|
|
const normalized = String(value ?? "").trim();
|
|
const matched = normalized.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
if (!matched) return null;
|
|
|
|
const year = Number(matched[1]);
|
|
const month = Number(matched[2]);
|
|
const day = Number(matched[3]);
|
|
const date = new Date(year, month - 1, day);
|
|
if (
|
|
date.getFullYear() !== year ||
|
|
date.getMonth() !== month - 1 ||
|
|
date.getDate() !== day
|
|
) {
|
|
return null;
|
|
}
|
|
return matched[0];
|
|
};
|