export default function formatDate(date, format) {
  const d = new Date(date);
  const year = d.getFullYear();
  const month = (d.getMonth() + 1).toString().padStart(2, '0');
  const day = d.getDate().toString().padStart(2, '0');
  const hours = d.getHours().toString().padStart(2, '0');
  const minutes = d.getMinutes().toString().padStart(2, '0');
  const seconds = d.getSeconds().toString().padStart(2, '0');

  switch (format) {
      case 'YYYY-MM-DD':
          return `${year}-${month}-${day}`;
      case 'YYYY':
          return `${year}`;
      case 'YYYY-MM':
          return `${year}-${month}`;
      case 'YYYY-MM-DD HH:MM:SS':
          return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      default:
          return date;
  }
}