mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-13 22:39:15 +00:00
fix broken datetime
This commit is contained in:
parent
25e01d9606
commit
59ebf0af73
4 changed files with 56 additions and 21 deletions
|
@ -5,18 +5,21 @@
|
|||
<script setup lang="ts">
|
||||
type DateTimeFormat = "relative" | "long" | "short" | "human";
|
||||
|
||||
const props = defineProps({
|
||||
date: {
|
||||
type: [Date, String],
|
||||
required: true,
|
||||
},
|
||||
format: {
|
||||
type: String as () => DateTimeFormat,
|
||||
default: "relative",
|
||||
},
|
||||
type Props = {
|
||||
date?: Date | string;
|
||||
format?: DateTimeFormat;
|
||||
};
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
date: undefined,
|
||||
format: "relative",
|
||||
});
|
||||
|
||||
const value = computed(() => {
|
||||
if (!props.date || !validDate(props.date)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return fmtDate(props.date, props.format);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue