export const formatDate = (value?: number) =>
  value
    ? new Intl.DateTimeFormat('en', { dateStyle: 'medium' }).format(value)
    : 'Never';

export const formatDateTime = (value?: number) =>
  value
    ? new Intl.DateTimeFormat('en', {
        dateStyle: 'medium',
        timeStyle: 'short',
      }).format(value)
    : 'Never';

export const titleize = (value?: string) =>
  value?.replaceAll('_', ' ') ?? 'unknown';

export const truncate = (value: string, length = 80) =>
  value.length > length ? `${value.slice(0, length - 3)}...` : value;
