LocaleUtils API
Set of functions used internally to localize the component.
In some cases, you may want to implement your own LocaleUtils
, or override some of its functions (see: Localization). For example, this code renders the month’s title as M/YYYY
instead of the default:
import DayPicker, { LocaleUtils } from "react-day-picker";
function formatMonthTitle(d, locale) {
return `${d.getMonth() + 1}/${d.getFullYear()}`
}
<DayPicker localeUtils={ { ...LocaleUtils, formatMonthTitle } } />
Functions
formatDay (day: Date, locale: string) ⇒ string
Format the string used as aria-label for the given day
.
formatMonthTitle (month: Date, locale: string) ⇒ string
Return the string used to format the month’s title for the given month
.
formatWeekdayLong (i: number, locale: string) ⇒ string
Return the string used to render the weekday’s long name (starting from0
as Sunday).
formatWeekdayShort (i: number, locale: string) ⇒ string
Return the string used to render the weekday’s short name, e.g. Mo
forMonday.
getFirstDayOfWeek (locale: string) ⇒ number
Return the first day of the week for the given locale (where 0
is Sunday).
getMonths (locale: string) ⇒ number
Return the twelve months for the given locale (full name, e.g. January
).