The NestJS API serves the public profile through Apollo Sandbox and loads only the relations selected by the query.
25 lines
499 B
TypeScript
25 lines
499 B
TypeScript
const PRESENT = 'н.в.';
|
||
|
||
export function formatPeriod(
|
||
startYear: number,
|
||
endYear: number | null,
|
||
): string {
|
||
if (endYear === null) {
|
||
return `${startYear} — ${PRESENT}`;
|
||
}
|
||
if (startYear === endYear) {
|
||
return String(startYear);
|
||
}
|
||
return `${startYear}–${endYear}`;
|
||
}
|
||
|
||
export function formatOptionalPeriod(
|
||
startYear: number | null,
|
||
endYear: number | null,
|
||
): string | null {
|
||
if (startYear === null) {
|
||
return null;
|
||
}
|
||
return formatPeriod(startYear, endYear);
|
||
}
|