@@ -19,6 +19,7 @@ import type { ModelValue, VueEmit, TimeModel, MonthModel, ModelTypeConverted } f
19
19
import type { AllPropsType } from '@/props' ;
20
20
import type { Ref } from 'vue' ;
21
21
import { getTimezoneOffset , localToTz } from '@/utils/timezone' ;
22
+ import { modelTypePredefined } from '@/constants' ;
22
23
23
24
/**
24
25
* Handles values from external to internal and vise versa
@@ -310,12 +311,16 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
310
311
return props . utc === 'preserve' ? new Date ( toDate . getTime ( ) + toDate . getTimezoneOffset ( ) * 60000 ) : toDate ;
311
312
}
312
313
if ( props . modelType ) {
313
- if ( props . modelType === 'date' || props . modelType === 'timestamp' ) return convertModelToTz ( new Date ( value ) ) ;
314
+ if ( modelTypePredefined . includes ( props . modelType ) ) return convertModelToTz ( new Date ( value ) ) ;
314
315
315
316
if ( props . modelType === 'format' && ( typeof props . format === 'string' || ! props . format ) )
316
- return convertModelToTz ( parse ( value as string , getDefaultPattern ( ) , new Date ( ) , { locale : formatLocale . value } ) ) ;
317
+ return convertModelToTz (
318
+ parse ( value as string , getDefaultPattern ( ) , new Date ( ) , { locale : formatLocale . value } ) ,
319
+ ) ;
317
320
318
- return convertModelToTz ( parse ( value as string , props . modelType , new Date ( ) , { locale : formatLocale . value } ) ) ;
321
+ return convertModelToTz (
322
+ parse ( value as string , props . modelType , new Date ( ) , { locale : formatLocale . value } ) ,
323
+ ) ;
319
324
}
320
325
321
326
return convertModelToTz ( new Date ( value ) ) ;
@@ -328,6 +333,7 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
328
333
}
329
334
if ( props . modelType ) {
330
335
if ( props . modelType === 'timestamp' ) return + convertZonedModelToLocal ( val ) ;
336
+ if ( props . modelType === 'iso' ) return convertZonedModelToLocal ( val ) . toISOString ( ) ;
331
337
332
338
if ( props . modelType === 'format' && ( typeof props . format === 'string' || ! props . format ) )
333
339
return formatDateFn ( convertZonedModelToLocal ( val ) ) ;
0 commit comments