@@ -118,6 +118,7 @@ export type DateInputProps = {
118
118
opened ?: boolean ;
119
119
defaultOpened ?: boolean ;
120
120
dateFormat ?: string ;
121
+ parsingFormats ?: string [ ] ;
121
122
includeTime ?: boolean ;
122
123
minDate ?: string ;
123
124
maxDate ?: string ;
@@ -142,6 +143,7 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
142
143
value : value_ ,
143
144
defaultValue,
144
145
dateFormat,
146
+ parsingFormats : parsingFormats_ ,
145
147
includeTime,
146
148
className,
147
149
cols,
@@ -171,6 +173,7 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
171
173
const [ value , setValue ] = useControlledValue ( value_ , defaultValue ?? null ) ;
172
174
const valueFormat = includeTime ? 'YYYY-MM-DDTHH:mm:ss.SSSZ' : 'YYYY-MM-DD' ;
173
175
const inputValueFormat = dateFormat || ( includeTime ? 'L HH:mm' : 'L' ) ;
176
+ const parsingFormats = parsingFormats_ ?? [ inputValueFormat ] ;
174
177
const dvalue = dayjs ( value ?? undefined , valueFormat ) ;
175
178
const [ inputValue_ , setInputValue ] = useState < string | null > ( null ) ;
176
179
const inputValue =
@@ -201,7 +204,7 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
201
204
if ( ! inputValue ) {
202
205
newValue = '' ;
203
206
} else {
204
- const dvalue = dayjs ( inputValue , inputValueFormat ) ;
207
+ const dvalue = dayjs ( inputValue , parsingFormats ) ;
205
208
if ( dvalue . isValid ( ) ) {
206
209
newValue = dvalue . format ( valueFormat ) ;
207
210
} else {
@@ -223,7 +226,7 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
223
226
const showDatepicker = useEventCallback ( ( ) => {
224
227
let newValue = value ;
225
228
if ( inputValue != null ) {
226
- const dvalue = dayjs ( inputValue , inputValueFormat ) ;
229
+ const dvalue = dayjs ( inputValue , parsingFormats ) ;
227
230
if ( dvalue . isValid ( ) ) {
228
231
newValue = dvalue . format ( valueFormat ) ;
229
232
}
0 commit comments