21 lines
500 B
TypeScript
21 lines
500 B
TypeScript
/**
|
||
* Formats the life date range for a person.
|
||
* Examples:
|
||
* * 1882 – † 1944 (both)
|
||
* * 1882 (birth only)
|
||
* † 1944 (death only)
|
||
* "" (neither)
|
||
*/
|
||
export function formatLifeDateRange(birthYear?: number | null, deathYear?: number | null): string {
|
||
if (birthYear && deathYear) {
|
||
return `* ${birthYear} – † ${deathYear}`;
|
||
}
|
||
if (birthYear) {
|
||
return `* ${birthYear}`;
|
||
}
|
||
if (deathYear) {
|
||
return `† ${deathYear}`;
|
||
}
|
||
return '';
|
||
}
|