import moment from "jalali-moment";
import React from "react";

const FormatJalaliDate = (date, noYear) => {
  const jalaliDateDay = moment(date).locale("fa").format("D");
  const jalaliDateYear = moment(date).locale("fa").format("YYYY");

  // Extract day name
  const dayName = moment(date).locale("fa").format("dddd");

  let result = null;

  // Map English day names to Persian

  // Get the Persian day name

  // Extract month name
  const monthName = moment(date).locale("fa").format("MMMM");

  if (noYear) {
    result = `${dayName} ${jalaliDateDay} ${monthName}`;
  } else {
    result = `${dayName} ${jalaliDateDay} ${monthName} ${jalaliDateYear}`;
  }

  return result;
};

export default FormatJalaliDate;
