diff --git a/components/QRCodeModal.vue b/components/QRCodeModal.vue index d8763fd..c018340 100644 --- a/components/QRCodeModal.vue +++ b/components/QRCodeModal.vue @@ -16,7 +16,7 @@

{{ sermon.title }}

-

{{ formatDate(sermon.date) }}

+

{{ formatDateRange(sermon) }}

@@ -51,7 +51,8 @@ const qrCanvas = ref(null) const config = useRuntimeConfig() 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', { year: 'numeric', 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 () => { if (qrCanvas.value) { const url = `${config.public.siteUrl}/${props.sermon.slug}`