Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arabic culture "ar-sa" DateTime error

I have the following scenario: my site is developed to work with different cultures (mainly Arabic and English) when the user select the culture "ar-sa" (from the internet explorer options) all date time pickers are converted in Hijri format. In one of my pages i have used the RadTimePicker telerik control, when i run this page from visual studio no error appears but when we have deployed this page on a site the following error has pope out:

Valid values are between 1318 and 1450, inclusive. Parameter name: year

I tried to deploy the page on the pc of my colleague (on a local IIS) the error appears. Then i tried to deploy it on my pc using IIS this time no error!!

please can anyone give me a hint on where to start to find the error

Thanks in advance

like image 426
Mazen313 Avatar asked Nov 11 '11 13:11

Mazen313


1 Answers

Any date time objects created in .NET with the CultureInfo of "ar-sa" will use the UmAlQuraCalendar object, which specifies that valid dates must have their year between 1318 and 1450. Check the .NET documentation for this object and you will see. For my project I had to load a date without the culture, then check its range against the current culture's calendar min and max year ranges, and if outside that range, turn the value into a value inside that range before parsing into a date time that was given the proper culture info object. Note that .NET date time objects are ALWAYS in gregorian. To see the date as a date in another calendar you must always look at it through the Calendar object that corresponds with the culture you're using.

like image 198
Rob Avatar answered Sep 22 '22 08:09

Rob