@@ -16,8 +16,8 @@ const DateTime: React.FC<Props> = (props) => {
1616 const {
1717 value,
1818 onChange,
19- displayFormat,
20- pickerAppearance = "dayOnly" ,
19+ displayFormat : customDisplayFormat ,
20+ pickerAppearance = 'default' ,
2121 minDate,
2222 maxDate,
2323 monthsToShow = 1 ,
@@ -39,20 +39,21 @@ const DateTime: React.FC<Props> = (props) => {
3939 console . warn ( `Could not find DatePicker locale for ${ locale } ` ) ;
4040 }
4141
42- let dateTimeFormat = displayFormat ;
42+ let dateFormat = customDisplayFormat ;
4343
44- if ( dateTimeFormat === undefined && pickerAppearance ) {
45- if ( pickerAppearance === 'dayAndTime' ) dateTimeFormat = 'MMM d, yyy h:mm a' ;
46- else if ( pickerAppearance === 'timeOnly' ) dateTimeFormat = 'h:mm a' ;
47- else if ( pickerAppearance === 'dayOnly' ) dateTimeFormat = 'dd' ;
48- else if ( pickerAppearance === 'monthOnly' ) dateTimeFormat = 'MMMM' ;
49- else dateTimeFormat = 'MMM d, yyy' ;
44+ if ( ! customDisplayFormat ) {
45+ // when no displayFormat is provided, determine format based on the picker appearance
46+ if ( pickerAppearance === 'default' ) dateFormat = 'MM/dd/yyyy' ;
47+ else if ( pickerAppearance === 'dayAndTime' ) dateFormat = 'MMM d, yyy h:mm a' ;
48+ else if ( pickerAppearance === 'timeOnly' ) dateFormat = 'h:mm a' ;
49+ else if ( pickerAppearance === 'dayOnly' ) dateFormat = 'MMM dd' ;
50+ else if ( pickerAppearance === 'monthOnly' ) dateFormat = 'MMMM' ;
5051 }
5152
5253 const dateTimePickerProps = {
5354 minDate,
5455 maxDate,
55- dateFormat : dateTimeFormat ,
56+ dateFormat,
5657 monthsShown : Math . min ( 2 , monthsToShow ) ,
5758 showTimeSelect : pickerAppearance === 'dayAndTime' || pickerAppearance === 'timeOnly' ,
5859 minTime,
0 commit comments