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

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

  // 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("jMMMM");

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

  return result;
};

export default FormatJalaliDate;
