import { HistoryDTO } from '@cmf/trade-api';

export function historyDtoToInfoText(history: HistoryDTO): string {
  const baseDate = new Date(history.changed);
  const format: Intl.DateTimeFormatOptions = {
    month: '2-digit',
    day: '2-digit',
    year: 'numeric',
  };

  const date = baseDate.toLocaleDateString('de', format);
  const time = `${baseDate.getHours()}:${('0' + baseDate.getMinutes()).slice(-2)} Uhr`;
  const location = history.location;

  return `${date} | ${time}${location ? ' | ' + location : ''}`;
}
