( start: string | Date | undefined, end: string | Date | undefined )
| 80 | * to a placeholder. |
| 81 | */ |
| 82 | export function formatDateRangeLabel( |
| 83 | start: string | Date | undefined, |
| 84 | end: string | Date | undefined |
| 85 | ): string { |
| 86 | const startDate = parseDateValue(start) |
| 87 | const endDate = parseDateValue(end) |
| 88 | if (!startDate && !endDate) return '' |
| 89 | if (startDate && !endDate) return formatDateLabel(startDate) |
| 90 | if (!startDate && endDate) return formatDateLabel(endDate) |
| 91 | if (!startDate || !endDate) return '' |
| 92 | const sameYear = startDate.getFullYear() === endDate.getFullYear() |
| 93 | const startLabel = startDate.toLocaleDateString('en-US', { |
| 94 | month: 'short', |
| 95 | day: 'numeric', |
| 96 | ...(sameYear ? {} : { year: 'numeric' }), |
| 97 | }) |
| 98 | const endLabel = endDate.toLocaleDateString('en-US', { |
| 99 | year: 'numeric', |
| 100 | month: 'short', |
| 101 | day: 'numeric', |
| 102 | }) |
| 103 | return `${startLabel} - ${endLabel}` |
| 104 | } |
| 105 | |
| 106 | function isSameDay(a: Date, b: Date): boolean { |
| 107 | return ( |
no test coverage detected