crbtc.org/components/event/Date.vue

23 lines
501 B
Vue

<script setup>
import { format, getDay, parseISO } from "date-fns";
const nth = function(d) {
if (d > 3 && d < 21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
let date = parseISO(data.value.date)
data.value.date = format(date, 'EEE, MMMM d')
data.value.ordinal = nth(getDay(date) - 1)
</script>
<template>
<h4>Date: {{ data.date }} · {{ data.time }}</h4>
</template>