export type DisplayTextValue = number | string | BusinessDay | null | undefined;
function isBusinessDay(value: unknown): value is BusinessDay {
return (
typeof value === 'object' &&
value !== null &&
'year' in value &&
'month' in value &&
'day' in value
);
}
export function formatDisplayText(value: DisplayTextValue): string {
if (value === null || value === undefined) {
return '';
}
if (typeof value === 'string' || typeof value === 'number') {
return String(value);
}
if (isBusinessDay(value)) {
const day = String(value.day).padStart(2, '0');
const month = String(value.month).padStart(2, '0');
return `${day}.${month}.${value.year}`;
}
return '';
}