aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/StudipDate.vue
blob: 2e30b9d250a5853d6dd23926119a8f7332f98001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<template>
    <time :datetime="date.toISOString()">{{ formatted }}</time>
</template>

<script>
function formatDate(date) {
    return pad(date.getDate()) + '.' + pad(date.getMonth() + 1) + '.' + date.getFullYear();
}

function pad(what) {
    return what.toString().padStart(2, '0');
}

export default {
    props: {
        date: {
            type: Date,
            required: true,
        },
    },
    computed: {
        formatted() {
            return formatDate(this.date);
        },
    },
};
</script>