diff --git a/src/lib/index.ts b/src/lib/index.ts index cd89bac6c..caeb21742 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -4,10 +4,12 @@ export function formatDonationDate(donation: Donation) { return formatDate(donation?.start_date, donation?.end_date); } -export function formatDate(startDate: string, endDate: string) { - return startDate !== endDate - ? `${new Date(startDate).toLocaleDateString()}–${new Date(endDate).toLocaleDateString()}` - : new Date(startDate).toLocaleDateString(); +export function formatDate(startDate: string, endDate: string, locale = 'en-GB') { + if (startDate === endDate) { + return new Intl.DateTimeFormat(locale).format(new Date(startDate)); + } + + return `${new Intl.DateTimeFormat(locale).format(new Date(startDate))}–${new Intl.DateTimeFormat(locale).format(new Date(endDate))}`; } export function formatEventDate(event: Event) {