Now i am working with Hijri dates and trying 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-M-d","dd-MM-yyyy","d-M-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 is working fine with all dates except the date that has 30th day in month like the following :
'30/10/1433' , '30/12/1432' or '30/05/1433' etc ..... so how to handle and convert that date with its corresponding Gregorian :S
here is the code it is working well now on this code I'm returning the date from the function as string not as datetime, but you can simply using reuturn datetime type instead on string
To call this Method here are an example
to call the Hijri
10th and 12nd months in Hirji don't have 30th day, so that date is invalid.
Max Value of a days in a month can be calculated by
DateTime.DaysInMonth(year, month)
and use it this way
but