Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed bun.lockb
Binary file not shown.
15 changes: 12 additions & 3 deletions packages/ui/src/components/Datepicker/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,27 @@ export const addYears = (date: Date, amount: number): Date => {
return newDate;
};

export const convertKoreanDateToISO = (dateStr: string): string => {
const match = dateStr.match(/(\d{4}).\s*(\d{2}).\s*(\d{2})./);

if (!match) return dateStr;

const [, year, month, day] = match;
return `${year}-${month}-${day}`;
};

export const getFormattedDate = (language: string, date: Date, options?: Intl.DateTimeFormatOptions): string => {
let defaultOptions: Intl.DateTimeFormatOptions = {
day: "numeric",
month: "long",
day: "2-digit",
month: "2-digit",
year: "numeric",
};

if (options) {
defaultOptions = options;
}

const formattedDate = new Intl.DateTimeFormat(language, defaultOptions).format(date);
const formattedDate = convertKoreanDateToISO(new Intl.DateTimeFormat(language, defaultOptions).format(date));
return formattedDate.length <= 3 ? formattedDate.replace("일", "").trim() : formattedDate;
};

Expand Down