I'm having trouble representing Persian (Solar Hijri Calendar) dates as DateTime
in C#, specifically on certain days of particular months, for example 31/04 where in the Gregorian calendar such a date is meaningless:
System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
DateTime date = new DateTime(2013,7,22);
int year = p.GetYear(date);
int month = p.GetMonth(date);
int day = p.GetDayOfMonth(date);
DateTime d1 = new DateTime(year, month, day);
The above code will result in an ArgumentOutOfRangeException
saying:
Year, Month, and Day parameters describe an un-representable DateTime.
Which is expected.
How can I represent Persian Dates as DateTime
s in .NET taking into accounts dates such as 30/02 and 31/04?