Closed zuhairkareem closed 3 years ago
Found that in MonthView.js file - https://github.com/mui-org/material-ui-pickers/blob/4ee37a74128c84d4152e8dcdd3b863b2605e521e/lib/src/views/Month/MonthView.tsx#L78,
But moment hijri has "iMMM" format to get Hijri months. I am confused about how to change this?
I extended utils to get the format I want. - https://codesandbox.io/s/material-hijri-calendar-forked-y9e68?file=/src/App.js
export default class HijriUtilsExtended extends HijriUtils {
format = function (date, format) {
return format === 'MMM' ? date.format('iMMM') : date.format(format);
}
// Get the months array in hijri.
getMonthArray = function (date) {
const firstMonth = date.clone().locale(this.locale).startOf("iYear");
const monthArray = [firstMonth];
while (monthArray.length < 12) {
const prevMonth = monthArray[monthArray.length - 1];
monthArray.push(prevMonth.clone().add(1, "iMonth"));
}
return monthArray;
}
// Set month in Hijri.
setMonth = function (date, count) {
return date.clone().iMonth(count);
};
}
I am using material UI datepicker with an option to show Hijri calendar. The issue is with the months shown in the month picker are gregorian (arabic translation of January, February etc) while the correct one should be Muharram, Safar etc..
Current Behavior 😯
Arabic translation of Gregorian months shown.
Expected Behavior 🤔
Hijri Months should be shown like Muharram, Safar etc
Steps to Reproduce 🕹
Steps:
Here is a link to codesandbox which has the same issue - https://codesandbox.io/s/7vx23?file=/src/App.js
Context 🔦
People using Hijri datepicker will be expecting Hijri months instead of Gregorian months for sure :)
Your Environment 🌎