import { Timestamp } from '../types/Timestamp';

/**
 * Convert date to nicer format
 * @param date Timestamp in question
 * @returns Formatted string
 */
const convertDate = (date: Timestamp): string => {
  return new Date(date.date).toLocaleString(navigator.languages[0] ?? 'de-DE', {
    timeZone: date.timezone,
    day: '2-digit',
    month: '2-digit',
    year: 'numeric',
    hour: '2-digit',
    hour12: false,
    minute: '2-digit',
  });
};

export default convertDate;
