import moment from "moment";

export function stringToDate(date: string) {
   const [dd, mm, yyyy] = date.split('-');
   return new Date(Number(yyyy), Number(mm) - 1, Number(dd))
}

export function stringToDateTime(date: string, time: string) {
   if (date == "" || date == "null" || date == undefined) {
      date = moment().format('DD-MM-YYYY')
   }

   const [dd, mm, yyyy] = date.split('-');
   const [hh, mi] = time.split(':');

   return new Date(Number(yyyy), Number(mm) - 1, Number(dd), Number(hh), Number(mi))
}