@@ -7,7 +7,7 @@ function checkShow(format: string, keywords: string[], show?: boolean) {
77}
88
99const showTimeKeys = [
10- 'format' ,
10+ // 'format',
1111 'showNow' ,
1212 'showHour' ,
1313 'showMinute' ,
@@ -31,18 +31,27 @@ const showTimeKeys = [
3131/**
3232 * Get SharedTimeProps from props.
3333 */
34- function pickTimeProps < DateType extends object = any > ( props : any ) : SharedTimeProps < DateType > {
34+ function pickTimeProps < DateType extends object = any > (
35+ props : any ,
36+ ) : [ timeProps : SharedTimeProps < DateType > , propFormat : string ] {
3537 const timeProps : any = pickProps ( props , showTimeKeys ) ;
38+ const { format, picker } = props ;
3639
37- if ( timeProps . format ) {
38- let format = timeProps . format ;
39- if ( Array . isArray ( format ) ) {
40- format = format [ 0 ] ;
40+ let propFormat : typeof format = null ;
41+ if ( format ) {
42+ propFormat = format ;
43+
44+ if ( Array . isArray ( propFormat ) ) {
45+ propFormat = propFormat [ 0 ] ;
4146 }
42- timeProps . format = typeof format === 'object' ? format . format : format ;
47+ propFormat = typeof propFormat === 'object' ? propFormat . format : propFormat ;
48+ }
49+
50+ if ( picker === 'time' ) {
51+ timeProps . format = propFormat ;
4352 }
4453
45- return timeProps ;
54+ return [ timeProps , propFormat ] ;
4655}
4756
4857function isStringFormat ( format : any ) : format is string {
@@ -68,11 +77,15 @@ export function getTimeProps<DateType extends object>(
6877 showTimeFormat : string ,
6978 propFormat : string ,
7079] {
71- const { showTime, picker } = componentProps ;
80+ const { showTime } = componentProps ;
7281
73- const pickedProps = pickTimeProps ( componentProps ) ;
74- const isShowTimeConfig = showTime && typeof showTime === 'object' ;
75- const timeConfig = isShowTimeConfig ? showTime : pickedProps ;
82+ const [ pickedProps , propFormat ] = pickTimeProps ( componentProps ) ;
83+
84+ const showTimeConfig = showTime && typeof showTime === 'object' ? showTime : { } ;
85+ const timeConfig = {
86+ ...pickedProps ,
87+ ...showTimeConfig ,
88+ } ;
7689
7790 const { showMillisecond } = timeConfig ;
7891 let { showHour, showMinute, showSecond } = timeConfig ;
@@ -83,12 +96,6 @@ export function getTimeProps<DateType extends object>(
8396 showSecond = true ;
8497 }
8598
86- const mergedFormat = isShowTimeConfig
87- ? showTime . format
88- : picker === 'time'
89- ? pickedProps . format
90- : null ;
91-
9299 return [
93100 timeConfig ,
94101 {
@@ -98,8 +105,8 @@ export function getTimeProps<DateType extends object>(
98105 showSecond,
99106 showMillisecond,
100107 } ,
101- mergedFormat ,
102- pickedProps . format ,
108+ timeConfig . format ,
109+ propFormat ,
103110 ] ;
104111}
105112
0 commit comments