(experiences: DurationRangeInput[])
| 118 | } |
| 119 | |
| 120 | export function formatTotalDuration(experiences: DurationRangeInput[]): string { |
| 121 | const ranges: DateRange[] = experiences.map((exp) => ({ |
| 122 | start: exp.startedAt ? new Date(exp.startedAt) : new Date(), |
| 123 | end: exp.endedAt ? new Date(exp.endedAt) : new Date(), |
| 124 | })); |
| 125 | |
| 126 | const { years, months } = calculateTotalDurationInMonths(ranges); |
| 127 | |
| 128 | if (years > 0) { |
| 129 | const yearCopy = `${years} ${pluralize('year', years)}`; |
| 130 | |
| 131 | if (months === 0) { |
| 132 | return yearCopy; |
| 133 | } |
| 134 | |
| 135 | return `${yearCopy} ${months} ${pluralize('month', months)}`; |
| 136 | } |
| 137 | |
| 138 | return months > 0 |
| 139 | ? `${months} ${pluralize('month', months)}` |
| 140 | : 'Less than a month'; |
| 141 | } |
no test coverage detected