chore(LastUpdated): ISO 8601 format, <time>

pull/486/head
Simon Legner 4 years ago
parent 1cb8a382f3
commit 680893d3f0

@ -16,17 +16,20 @@ const prefix = computed(() => {
}) })
const datetime = ref('') const datetime = ref('')
const datetimeFormatted = computed(() =>
datetime.value.replace(/T/, ' ').replace(/\.\d\d\dZ/, ' UTC')
)
onMounted(() => { onMounted(() => {
// locale string might be different based on end user // locale string might be different based on end user
// and will lead to potential hydration mismatch if calculated at build time // and will lead to potential hydration mismatch if calculated at build time
datetime.value = new Date(page.value.lastUpdated).toLocaleString('en-US') datetime.value = new Date(page.value.lastUpdated).toISOString()
}) })
</script> </script>
<template> <template>
<p v-if="hasLastUpdated" class="last-updated"> <p v-if="hasLastUpdated" class="last-updated">
<span class="prefix">{{ prefix }}:</span> <span class="prefix">{{ prefix }}:</span>
<span class="datetime">{{ datetime }}</span> <time :datetime="datetime">{{ datetimeFormatted }}</time>
</p> </p>
</template> </template>
@ -50,7 +53,7 @@ onMounted(() => {
font-weight: 500; font-weight: 500;
} }
.datetime { time {
display: inline-block; display: inline-block;
margin-left: 6px; margin-left: 6px;
font-weight: 400; font-weight: 400;

Loading…
Cancel
Save