it_solutions_test/src/profile/domain/period.ts
Илья Братских bd22447bd3 Add a GraphQL digital card that migrates and seeds itself on startup.
The NestJS API serves the public profile through Apollo Sandbox and loads only the relations selected by the query.
2026-11-02 05:30:54 +03:00

25 lines
499 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}