homebox/frontend/components/global/DateTime.vue
Hayden 4c9ddac395
fix: date picker improvements (#793)
* use vue component for date picker

* zero out database fields even when set to 0001-xx-xx

* fix wrong datetime display + improved datepicker

* fix ts error

* zero out times

* add date-fns to dependencies
2024-02-29 09:58:26 -09:00

27 lines
554 B
Vue

<template>
{{ value }}
</template>
<script setup lang="ts">
import { DateTimeFormat, DateTimeType } from "~~/composables/use-formatters";
type Props = {
date?: Date | string;
format?: DateTimeFormat;
datetimeType?: DateTimeType;
};
const props = withDefaults(defineProps<Props>(), {
date: undefined,
format: "relative",
datetimeType: "date",
});
const value = computed(() => {
if (!props.date || !validDate(props.date)) {
return "";
}
return fmtDate(props.date, props.format);
});
</script>