web/plugins/FormatJalaliDateEn/page.jsx

30 lines
672 B
JavaScript

import moment from "jalali-moment";
import React from "react";
const FormatJalaliDateEn = (date, noYear) => {
const jalaliDateDay = moment(date).format("D");
const jalaliDateYear = moment(date).format("YYYY");
// Extract day name
const dayName = moment(date).format("dddd");
let result = null;
// Map English day names to Persian
// Get the Persian day name
// Extract month name
const monthName = moment(date).format("MMMM");
if (noYear) {
result = `${dayName} ${jalaliDateDay} ${monthName}`;
} else {
result = `${dayName} ${jalaliDateDay} ${monthName} ${jalaliDateYear}`;
}
return result;
};
export default FormatJalaliDateEn;