2020-11-22 12:57:28 +01:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "DateTime",
|
|
|
|
methods: {
|
2021-01-05 00:50:24 +01:00
|
|
|
formatDate(date, year=false) {
|
|
|
|
if (typeof date === 'string')
|
|
|
|
date = new Date(Date.parse(date))
|
|
|
|
|
2021-01-14 00:15:35 +01:00
|
|
|
return date.toDateString().substring(0, year ? 15 : 10)
|
2020-11-22 12:57:28 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
formatTime(date, seconds=true) {
|
2021-01-05 00:50:24 +01:00
|
|
|
if (typeof date === 'string')
|
|
|
|
date = new Date(Date.parse(date))
|
|
|
|
|
2020-11-22 12:57:28 +01:00
|
|
|
return date.toTimeString().substring(0, seconds ? 8 : 5)
|
|
|
|
},
|
2021-01-14 00:15:35 +01:00
|
|
|
|
|
|
|
formatDateTime(date, year=false, seconds=true) {
|
|
|
|
if (typeof date === 'string')
|
|
|
|
date = new Date(Date.parse(date))
|
|
|
|
|
|
|
|
return `${this.formatDate(date, year)}, ${this.formatTime(date, seconds)}`
|
|
|
|
},
|
2020-11-22 12:57:28 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|