Base solution for your next web application
Open Closed

How to use Gregorian calendar with all languages #6103


User avatar
0
samara081 created

Hello,

When we switch to Arabic language, (ar-sa) the system switch the calendar to sometimes Hijri and sometimes to converted strange calendar. and when we create or edit any item, we received a date time conversion error.

Is there any way to force the system to use Gregorian calendar even with Arabic language?

And the error from the log:

ERROR 2018-12-06 12:12:03,174 [53 ] Mvc.ExceptionHandling.AbpExceptionFilter - String '١٢/‏٦/‏٢٠١٨' was not recognized as a valid DateTime. System.FormatException: String '١٢/‏٦/‏٢٠١٨' was not recognized as a valid DateTime. at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) at Newtonsoft.Json.Converters.IsoDateTimeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Abp.Json.AbpDateTimeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in D:\Github\aspnetboilerplate\src\Abp\Json\AbpDateTimeConverter.cs:line 22 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Formatters.JsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value) at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @samara081

    You can check https://support.aspnetzero.com/QA/Questions/4547, it is done before.

  • User Avatar
    0
    samara081 created

    Thank ismcagdas for your reply,

    I tried to follow all the steps in the thread and solved some issues, however I still miss one point.

    We have AspNetCore-MVC template (Not Angular), we did the following:

    1. On AbpServiceBase, we have added the following: Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); This has fixed the server side date formatting
    2. On _layout, we have added the following line on moment script section abp.localization.currentLanguage.name = 'en'; This fixed the calendar control data time, now we can add and edit without any issue.
    3. Last part which is still not working is data in data table and view pages, where it still display the data in Hijri. Where the data has been retrun correctly from the application, but in fiddler as well as the view pages it was on Hijri I tried RequestCultureProvider , but still not working
  • User Avatar
    0
    samara081 created

    Ok AbpUserRequestCultureProvider working fine, i just put it in thw wrong place

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :). This is a really tough issue :).

  • User Avatar
    0
    worldofss created

    can you please give us steps you produce ?