Skip to content

Commit

Permalink
Parse date value from primevue #147
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Jan 8, 2025
1 parent 03843fe commit 595ed96
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ watch(
modelValue.value = newValue;
},
);
// Datepicker returns date object, which needs to be parsed to post back
// https://github.com/primefaces/primevue/issues/6278
function parseDate(date: unknown): string | null {
if (date) {
return new Date(date as string).toISOString().split("T")[0];
}
return null;
}
</script>

<template>
Expand All @@ -26,6 +35,6 @@ watch(
icon-display="input"
:date-format="dateFormat"
show-icon
@update:model-value="() => emit('update', modelValue)"
@update:model-value="() => emit('update', parseDate(modelValue))"
/>
</template>

0 comments on commit 595ed96

Please sign in to comment.