@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
22import { range } from "./range" ;
33import { compileDateString , parseDateString } from "./date-string" ;
44import { Option , Options } from "./types" ;
5+ import { useUtils } from "./LocalizationProvider/useUtils" ;
56
67const DEFAULT_MIN_YEAR = 1960 ;
78const DEFAULT_MAX_YEAR = new Date ( ) . getFullYear ( ) ;
@@ -17,9 +18,6 @@ function compileOption(value: string): Option {
1718 return { value, label : value } ; // TODO: Be customizable for localization
1819}
1920
20- const monthOptions : Options = range ( 1 , 12 ) . map ( ( i ) =>
21- compileOption ( convertToSelectValue ( i ) )
22- ) ;
2321const dayOptions : Options = range ( 1 , 31 ) . map ( ( i ) =>
2422 compileOption ( convertToSelectValue ( i ) )
2523) ;
@@ -169,6 +167,8 @@ export const useDateSelect = (
169167 }
170168 } , [ setDate , value ] ) ;
171169
170+ const utils = useUtils ( ) ;
171+
172172 const yearOptions = useMemo ( ( ) => {
173173 const minYear = opts . minYear != null ? opts . minYear : DEFAULT_MIN_YEAR ;
174174 const maxYear = opts . maxYear != null ? opts . maxYear : DEFAULT_MAX_YEAR ;
@@ -182,6 +182,15 @@ export const useDateSelect = (
182182 return raw ;
183183 } , [ opts . minYear , opts . maxYear , state . yearValue ] ) ;
184184
185+ const monthOptions : Options = useMemo ( ( ) => {
186+ return range ( 1 , 12 ) . map ( ( i ) => {
187+ const label = utils
188+ ? utils . format ( new Date ( 1960 , i - 1 , 1 ) , "monthShort" )
189+ : convertToSelectValue ( i ) ;
190+ return { value : convertToSelectValue ( i ) , label } ;
191+ } ) ;
192+ } , [ utils ] ) ;
193+
185194 return {
186195 yearValue : state . yearValue ,
187196 monthValue : state . monthValue ,
0 commit comments