I want to change Persian date to standard DateTime
format in C# using Persian calendar class.
but because of changing the year to 1400
, it throws an exception like this:
ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 22/03/22 12:00:00 AM (Gregorian date) and 99/12/31 11:59:59 PM (Gregorian date), inclusive. (Parameter 'time')
Actual value was 0.
I checked the persian calendar class and I found this:
if (year < 1 || year > MaxCalendarYear || month < 1 || month > 12)
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
that throws exception. now what should I do to solve this problem?
Why not explict conversion with a help of PersianCalendar class?
Outcome:
ArgumentOutOfRangeException
is thrown when at least one of arguments is out of range:month
should be within1..12
etc.