Skip to content

Commit

Permalink
Merge pull request #788 from fanta759/main
Browse files Browse the repository at this point in the history
fix(ExternalInternalMapper): Take format-locale as locale when parsing date
  • Loading branch information
Jasenkoo authored Mar 28, 2024
2 parents f5dcdcd + 660676f commit 8a8fa61
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/VueDatePicker/composables/external-internal-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is

const inputValue = ref('');
const formatRef = toRef(props, 'format');
const formatLocale = toRef(props, 'formatLocale');

watch(
internalModelValue,
Expand Down Expand Up @@ -312,9 +313,9 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
if (props.modelType === 'date' || props.modelType === 'timestamp') return convertModelToTz(new Date(value));

if (props.modelType === 'format' && (typeof props.format === 'string' || !props.format))
return convertModelToTz(parse(value as string, getDefaultPattern(), new Date()));
return convertModelToTz(parse(value as string, getDefaultPattern(), new Date(), { locale: formatLocale.value }));

return convertModelToTz(parse(value as string, props.modelType, new Date()));
return convertModelToTz(parse(value as string, props.modelType, new Date(), { locale: formatLocale.value }));
}

return convertModelToTz(new Date(value));
Expand Down

0 comments on commit 8a8fa61

Please sign in to comment.