fix: update date formatting and locale handling in DatePicker and Calendar components

This commit is contained in:
Yoga Pangestu 2026-08-14 04:53:47 +07:00
parent 45a970e2f1
commit b4e4f2119a
2 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import { format } from 'date-fns';
import { id } from 'date-fns/locale';
import { id as idLocale } from 'react-day-picker/locale';
import { CalendarIcon } from 'lucide-react';
import * as React from 'react';
@ -59,7 +59,7 @@ function DatePicker({
return '';
}
return format(date, 'dd MMM yyyy', { locale: id });
return format(date, 'dd MMM yyyy', { locale: idLocale });
}, [date]);
return (
@ -82,6 +82,7 @@ return '';
<PopoverContent className="w-auto p-0" align="start">
<Calendar
mode="single"
locale={idLocale}
selected={date}
onSelect={(selectedDate) => {
onChange?.(selectedDate);

View File

@ -38,8 +38,8 @@ function Calendar({
)}
captionLayout={captionLayout}
formatters={{
formatMonthDropdown: (date) =>
date.toLocaleString("default", { month: "short" }),
formatMonthDropdown: (date, options) =>
date.toLocaleString(options?.locale?.code ?? "id", { month: "short" }),
...formatters,
}}
classNames={{