import { getMonthName } from '$lib/monthName';
/**
 * @param {string} date - Fecha del evento
 * @returns {string} - Fecha en dia (número) mes (letras)
 */
export const convertDate = (date) => {
  if (date == undefined) {
    return '';
  }
		/** @type {string} */ const monthNumber = date.split('-')[1];
		/** @type {string} */ let day = date.split('-')[2].split('T')[0];
		/** @type {number} */ const dayNumber = Number(day);
		/** @type {string} */ const month = getMonthName(monthNumber);

  /** Removes 0 on single digit days */
  if (dayNumber < 10) {
    day = day.charAt(1);
  }

		/** @type {string} */ const res = `${day} de ${month}`;
  return res;
};

