import { format, parseISO, getTime, setHours, setMinutes, formatDistanceToNow } from 'date-fns';

// ----------------------------------------------------------------------

export function fDate(date: Date | string | number) {
  //console.log(date);
  return format(new Date(date), 'dd MMMM yyyy');
}

export function fDateTime(date: Date | string | number) {
  return format(new Date(date), 'dd MMM yyyy HH:mm');
}

export function fTimestamp(date: Date | string | number) {
  return getTime(new Date(date));
}

export function fDateTimeSuffix(date: Date | string | number) {
  return format(new Date(date), 'dd/MM/yyyy hh:mm p');
}


export function fDateSuffix(date: Date | string | number) {
  return format(new Date(date), 'dd MMM yyyy');
}

export function fToNow(date: Date | string | number) {
  return formatDistanceToNow(new Date(date), {
    addSuffix: true,
  });
}

export function fPostFormat(date: Date | string | number, dateFormat = 'yyyy-MM-dd HH:mm:ss') {
  return format(new Date(date), dateFormat);
}

// export function fDateString(date) {
//   const dateObj = parseISO(date);
//   const formattedDate = format(dateObj, 'dd MMMM yyyy');
//   return formattedDate;
// }

// export function fFormattedDateString(date : String) {
//   console.log(date);
//   const datePart = date.split(' ')[0]; // Memisahkan bagian tanggal
//   const formattedDate = fDateString(datePart); // Menggunakan fungsi sebelumnya untuk memformat tanggal
//   return formattedDate;
// }
