File tree Expand file tree Collapse file tree 2 files changed +60
-52
lines changed Expand file tree Collapse file tree 2 files changed +60
-52
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ const generateConfig: GenerateConfig<Date> = {
7171 getWeek : ( locale , date ) => {
7272 return getWeek ( date , { locale : Locale [ dealLocal ( locale ) ] } ) ;
7373 } ,
74+ getShortWeekDays : locale => {
75+ const clone = Locale [ dealLocal ( locale ) ] ;
76+ return Array . from ( { length : 7 } ) . map ( ( _ , i ) => clone . localize . day ( i , { width : 'short' } ) ) ;
77+ } ,
78+ getShortMonths : locale => {
79+ const clone = Locale [ dealLocal ( locale ) ] ;
80+ return Array . from ( { length : 12 } ) . map ( ( _ , i ) =>
81+ clone . localize . month ( i , { width : 'abbreviated' } ) ,
82+ ) ;
83+ } ,
7484 format : ( locale , date , format ) => {
7585 if ( ! isValid ( date ) ) {
7686 return null ;
Original file line number Diff line number Diff line change @@ -144,59 +144,57 @@ describe('Picker.Generate', () => {
144144 ) . toEqual ( null ) ;
145145 } ) ;
146146
147- if ( name !== 'date-fns' ) {
148- it ( 'getShortWeekDays' , ( ) => {
149- expect ( generateConfig . locale . getShortWeekDays ! ( 'zh_CN' ) ) . toEqual ( [
150- 'ζ₯' ,
151- 'δΈ' ,
152- 'δΊ' ,
153- 'δΈ' ,
154- 'ε' ,
155- 'δΊ' ,
156- 'ε
' ,
157- ] ) ;
158- expect ( generateConfig . locale . getShortWeekDays ! ( 'en_US' ) ) . toEqual ( [
159- 'Su' ,
160- 'Mo' ,
161- 'Tu' ,
162- 'We' ,
163- 'Th' ,
164- 'Fr' ,
165- 'Sa' ,
166- ] ) ;
167- } ) ;
147+ it ( 'getShortWeekDays' , ( ) => {
148+ expect ( generateConfig . locale . getShortWeekDays ! ( 'zh_CN' ) ) . toEqual ( [
149+ 'ζ₯' ,
150+ 'δΈ' ,
151+ 'δΊ' ,
152+ 'δΈ' ,
153+ 'ε' ,
154+ 'δΊ' ,
155+ 'ε
' ,
156+ ] ) ;
157+ expect ( generateConfig . locale . getShortWeekDays ! ( 'en_US' ) ) . toEqual ( [
158+ 'Su' ,
159+ 'Mo' ,
160+ 'Tu' ,
161+ 'We' ,
162+ 'Th' ,
163+ 'Fr' ,
164+ 'Sa' ,
165+ ] ) ;
166+ } ) ;
168167
169- it ( 'getShortMonths' , ( ) => {
170- expect ( generateConfig . locale . getShortMonths ! ( 'zh_CN' ) ) . toEqual ( [
171- '1ζ' ,
172- '2ζ' ,
173- '3ζ' ,
174- '4ζ' ,
175- '5ζ' ,
176- '6ζ' ,
177- '7ζ' ,
178- '8ζ' ,
179- '9ζ' ,
180- '10ζ' ,
181- '11ζ' ,
182- '12ζ' ,
183- ] ) ;
184- expect ( generateConfig . locale . getShortMonths ! ( 'en_US' ) ) . toEqual ( [
185- 'Jan' ,
186- 'Feb' ,
187- 'Mar' ,
188- 'Apr' ,
189- 'May' ,
190- 'Jun' ,
191- 'Jul' ,
192- 'Aug' ,
193- 'Sep' ,
194- 'Oct' ,
195- 'Nov' ,
196- 'Dec' ,
197- ] ) ;
198- } ) ;
199- }
168+ it ( 'getShortMonths' , ( ) => {
169+ expect ( generateConfig . locale . getShortMonths ! ( 'zh_CN' ) ) . toEqual ( [
170+ '1ζ' ,
171+ '2ζ' ,
172+ '3ζ' ,
173+ '4ζ' ,
174+ '5ζ' ,
175+ '6ζ' ,
176+ '7ζ' ,
177+ '8ζ' ,
178+ '9ζ' ,
179+ '10ζ' ,
180+ '11ζ' ,
181+ '12ζ' ,
182+ ] ) ;
183+ expect ( generateConfig . locale . getShortMonths ! ( 'en_US' ) ) . toEqual ( [
184+ 'Jan' ,
185+ 'Feb' ,
186+ 'Mar' ,
187+ 'Apr' ,
188+ 'May' ,
189+ 'Jun' ,
190+ 'Jul' ,
191+ 'Aug' ,
192+ 'Sep' ,
193+ 'Oct' ,
194+ 'Nov' ,
195+ 'Dec' ,
196+ ] ) ;
197+ } ) ;
200198
201199 it ( 'getWeek' , ( ) => {
202200 const formatStr = name === 'date-fns' ? 'yyyy-MM-dd' : 'YYYY-MM-DD' ;
You canβt perform that action at this time.
0 commit comments