Improved time handling
Signed-off-by: Louis Hollingworth <louis@hollingworth.ch>
This commit is contained in:
parent
426ae17597
commit
c180404e15
6 changed files with 77 additions and 90 deletions
40
src/components/TimeFormat.vue
Normal file
40
src/components/TimeFormat.vue
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<script setup lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
type TimeFormatProps = {
|
||||
day: string | undefined,
|
||||
month: string | undefined,
|
||||
year: string | undefined,
|
||||
hour: string | undefined,
|
||||
minute: string | undefined,
|
||||
second: string | undefined,
|
||||
weekday: string | undefined,
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
formats: {
|
||||
type: Array<TimeFormatProps>,
|
||||
required: true,
|
||||
},
|
||||
dFormat: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const crntTime = Date.now();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<code>
|
||||
{{ `<t:${Math.floor(crntTime / 1000)}:${props.dFormat}>` }}
|
||||
</code>
|
||||
<span>
|
||||
to get
|
||||
<code>
|
||||
<span v-for="format in props.formats" :key="formats.findIndex(format)">
|
||||
{{Intl.DateTimeFormat(Intl.Locale, format).format(crntTime) + ' '}}
|
||||
</span>
|
||||
</code>
|
||||
</span>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue