Now I work with hijri dates and try to convert them to Gregorian dates using the following code:
string HijriDate; string[] allFormats ={"yyyy/MM/dd","yyyy/M/d", "dd/MM/yyyy","d/M/yyyy", "dd/M/yyyy","d/MM/yyyy","yyyy-MM-dd", "yyyy-Md","dd-MM-yyyy","dM-yyyy", "dd-M-yyyy","d-MM-yyyy","yyyy MM dd", "yyyy M d","dd MM yyyy","d M yyyy", "dd M yyyy","d MM yyyy","MM/dd/yyyy"}; CultureInfo enCul = new CultureInfo("en-US"); CultureInfo arCul = new CultureInfo("ar-SA"); arCul.DateTimeFormat.Calendar = new System.Globalization.HijriCalendar(); DateTime tempDate = DateTime.ParseExact(HijriDate, allFormats, arCul.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces); return tempDate.ToString("MM/dd/yyyy");
this code works fine with all dates except for a date that has a 30th day in a month, as shown below:
'30 / 10/1433 ', '30 / 12/1432' or '30 / 05/1433 ', etc ... ... so how to process and convert this date with the corresponding Gregorian: S
source share