devbridge / BetterCMS

A publishing focused and developer friendly .NET Open Source CMS.
GNU Lesser General Public License v3.0
375 stars 151 forks source link

Converting date time to string fails, when browser's default language is set to arabic #1007

Closed Audrunas closed 10 years ago

Audrunas commented 10 years ago

DateTime in Arabic fails when converting to date time string (when opening site settings -> pages): image

image

An exception is thrown:

Parameter name: time System.ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive.
Parameter name: time
   at System.Globalization.UmAlQuraCalendar.CheckTicksRange(Int64 ticks)
   at System.Globalization.UmAlQuraCalendar.GetDatePart(DateTime time, Int32 part)
   at System.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
   at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
   at BetterCms.Module.Root.Mvc.Converters.ToFormattedDateString(DateTime dateTime) in d:\Projects\BCMS\Code\MAIN\Modules\BetterCms.Module.Root\Mvc\Converters.cs:line 96
   at lambda_method(Closure , SiteSettingPageViewModel )
   at MvcContrib.UI.Grid.GridRenderer`1.RenderCellValue(GridColumn`1 column, GridRowViewData`1 rowData)
   at MvcContrib.UI.Grid.GridRenderer`1.RenderItem(GridRowViewData`1 rowData)
   at MvcContrib.UI.Grid.GridRenderer`1.RenderItems()
   at MvcContrib.UI.Grid.GridRenderer`1.Render(IGridModel`1 gridModel, IEnumerable`1 dataSource, TextWriter output, ViewContext context)
   at MvcContrib.UI.Grid.Grid`1.ToHtmlString()
   at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content)
[....]

The date is wrong in content edit forms also:

image

It seems, that different calendar is used (Hijri vs Gregorian): http://www.islamicfinder.org/dateConversion.php

Audrunas commented 10 years ago

Maybe Persian jQuery datepicker could help: http://plugins.jquery.com/pwt.datepicker/

Audrunas commented 10 years ago

After changes are done, write a message in support forum:http://www.bettercms.com/support/using-bettercms/using-persianhijri-date-in-entire-system-date-input-and-representation-fields/ and http://www.bettercms.com/support/themes/how-to-use-persian-calender-in-date-picker/

Audrunas commented 10 years ago

Fixed bug, described in title / issue description. FIx will be available from 1.6.0-beta3+

Audrunas commented 10 years ago

For persian / arabic calendar support created new issue #1015 to the future versions