260914_01_ENH: 1차 완성

This commit is contained in:
2026-09-14 15:07:40 +09:00
parent a6642c9a00
commit f1d21d3711
67 changed files with 5595 additions and 148 deletions

13
src/lib/kmusical/date.ts Normal file
View File

@@ -0,0 +1,13 @@
export const toLocalDateString = (date = new Date()) => {
const pad = (value: number) => String(value).padStart(2, "0");
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
};
export const parseLocalDateString = (value: string | undefined | null): Date | null => {
const match = value ? /^(\d{4})-(\d{2})-(\d{2})/.exec(value) : null;
if (!match) return null;
const [, year, month, day] = match;
const date = new Date(Number(year), Number(month) - 1, Number(day));
return Number.isNaN(date.getTime()) ? null : date;
};