I have a method
DateToString(DateTime datetime, string format, CultureInfo cultrueInfo)
{
return datetime.ToString(format, cultureInfo);
}
Parameters:
datetime: {10/1/2016 12:00:00 AM}
format: "ddd, dd MMM"
cultureInfo: {ar-SA}
But it returns me "السبت, 30 ذو الحجة". October 1st is Saturday. Why it seems return me September 30, Saturday? Anything wrong at my side?
ar-SA
culture uses UmAlQuraCalendar
a calendar.
new CultureInfo("ar-SA").Calendar.Dump(); // System.Globalization.UmAlQuraCalendar
Since you used that culture in your ToString
method, it will generated a string representation based on that calendar. You can't expect to generate "September" since your culture does not use GregorianCalendar
.
In UmAlQuraCalendar
, your DateTiem will be represented as 30-12-1437.
var dt = new DateTime(2016, 10, 1); // Gregorian
var umAlQura = new UmAlQuraCalendar();
umAlQura.GetYear(dt); // 1437
umAlQura.GetMonth(dt); // 12
umAlQura.GetDayOfMonth(dt); // 30
https://www.staff.science.uu.nl/~gent0113/islam/ummalqura_converter.htm
That's why:
ddd
format specifier generates السبت ((Yawm) as-Sabt aka Saturday) since it is the abbreviated day name.dd
format specifier generates 30
as expected.MMM
format specifier generates ذو الحجة (Dhu al-Hijjah) since it is the abbreviated month name.As you can see, abbreviated day and month name switched in result. This is probably a Right to left issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With