QR code dates
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<div class="text-center mb-4">
|
<div class="text-center mb-4">
|
||||||
<h4 class="text-lg font-semibold text-gray-900 mb-1">{{ sermon.title }}</h4>
|
<h4 class="text-lg font-semibold text-gray-900 mb-1">{{ sermon.title }}</h4>
|
||||||
<p class="text-sm text-gray-600">{{ formatDate(sermon.date) }}</p>
|
<p class="text-sm text-gray-600">{{ formatDateRange(sermon) }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-white p-4 rounded-lg border-2 border-gray-200">
|
<div class="bg-white p-4 rounded-lg border-2 border-gray-200">
|
||||||
<canvas ref="qrCanvas"></canvas>
|
<canvas ref="qrCanvas"></canvas>
|
||||||
@@ -51,7 +51,8 @@ const qrCanvas = ref<HTMLCanvasElement | null>(null)
|
|||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
function formatDate(dateString: string) {
|
function formatDate(dateString: string) {
|
||||||
const date = new Date(dateString)
|
// Add T00:00:00 to ensure the date is interpreted as local time, not UTC
|
||||||
|
const date = new Date(dateString + 'T00:00:00')
|
||||||
return date.toLocaleDateString('en-US', {
|
return date.toLocaleDateString('en-US', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
@@ -59,6 +60,24 @@ function formatDate(dateString: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDateRange(sermon: any) {
|
||||||
|
// Start with primary date
|
||||||
|
const dates = [sermon.date]
|
||||||
|
|
||||||
|
// Add additional dates if they exist
|
||||||
|
if (sermon.dates) {
|
||||||
|
try {
|
||||||
|
const additionalDates = JSON.parse(sermon.dates)
|
||||||
|
dates.push(...additionalDates)
|
||||||
|
} catch {
|
||||||
|
// If parsing fails, just use primary date
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format all dates and join with " - "
|
||||||
|
return dates.map(formatDate).join(' - ')
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (qrCanvas.value) {
|
if (qrCanvas.value) {
|
||||||
const url = `${config.public.siteUrl}/${props.sermon.slug}`
|
const url = `${config.public.siteUrl}/${props.sermon.slug}`
|
||||||
|
|||||||
Reference in New Issue
Block a user