2020-04-21 16:23:43 +02:00
|
|
|
<template>
|
|
|
|
|
<span class="ui-date" v-html="output"></span>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-12-19 01:16:02 +01:00
|
|
|
import { formatDate } from '../utils/dates';
|
2020-04-21 16:23:43 +02:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'uiDate',
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
value: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: null
|
2020-05-07 15:03:29 +02:00
|
|
|
},
|
|
|
|
|
format: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: null
|
2020-08-17 14:46:13 +02:00
|
|
|
},
|
|
|
|
|
split: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
2020-04-21 16:23:43 +02:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
|
output: null
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
value: function (value)
|
|
|
|
|
{
|
|
|
|
|
this.rebuild();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted()
|
|
|
|
|
{
|
|
|
|
|
this.rebuild();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
{
|
|
|
|
|
if (!this.value)
|
|
|
|
|
{
|
|
|
|
|
this.output = '';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-17 14:46:13 +02:00
|
|
|
if (!this.split)
|
|
|
|
|
{
|
2021-12-19 01:16:02 +01:00
|
|
|
this.output = formatDate(this.value, this.format);
|
2020-08-17 14:46:13 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-19 01:16:02 +01:00
|
|
|
this.output = formatDate(this.value, 'short') + ' <span class="-minor">' + formatDate(this.value, 'time') + '</span>';
|
2020-08-17 14:46:13 +02:00
|
|
|
}
|
2020-04-21 16:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2020-08-17 14:46:13 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.ui-date .-minor
|
|
|
|
|
{
|
2020-09-07 14:55:05 +02:00
|
|
|
color: var(--color-text-dim);
|
2020-08-17 14:46:13 +02:00
|
|
|
}
|
|
|
|
|
</style>
|