diff --git a/api/src/utils/datetime.ts b/api/src/utils/datetime.ts index 0a3bd72..8385ed8 100644 --- a/api/src/utils/datetime.ts +++ b/api/src/utils/datetime.ts @@ -25,6 +25,17 @@ export function asHour(date?: Date) { return date ? formatDateTime(date, false, true) : ''; } +export function formatStartEnd(start: Date, end?: Date) { + const today = asDate(new Date()); + const startDate = asDate(start); + const endDate = end ? asDate(end) : ''; + return ( + (today !== startDate ? `${startDate}, ` : '') + + asHour(start) + + (end ? ' - ' + (endDate !== startDate ? `${endDate}, ` : '') + asHour(end) : '') + ); +} + export function startOfWeek(date: Date, startMonday = true) { const start = new Date(date); const day = date.getDay() || 7;