question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Arabic Date issues

See original GitHub issue

Dears, I faced issues when dealing with Dates in Arabic Language All of my entities are audited entities and they have CreationTime that i need to display on each screen or grid. First Issue, I want dates to be saved in db as UTC so, i changed the clock provider in startup class

        {
            //Initializes ABP framework.
            app.UseAbp(options =>
            {
                options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization
                Clock.Provider = ClockProviders.Utc;
            });}

but when i displayed them using Arabic language, i got something like that issue1 The expected behavior should be CreationDate should be displayed in full Gregorian date

Second Issue:- When i try to update existing entity in Arabic language, The date is saved in database in Hijri Althouth i changed my default clock provider to be utc 1439-10-13 15:27:27.7960000 This is the date that is saved in my sql server when updating existing entity and this issue break our application @acjh @hikalkan @ismcagdas

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FirasKiracommented, May 23, 2019

Thank you very much Ismail. It works fine.

I just want to mention an important point! If you want to give the user the ability to switch between two languages (in my case English and Arabic) then as you said you need to execute other request culture localizers in your custom class (like this one https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.AspNetCore/AspNetCore/Localization/AbpUserRequestCultureProvider.cs). Using this class as it is won’t work and you need to modify as follow:

public override async Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext)
        {
            var abpSession = httpContext.RequestServices.GetRequiredService<IAbpSession>();
            if (abpSession.UserId == null)
            {
                return null;
            }

            var settingManager = httpContext.RequestServices.GetRequiredService<ISettingManager>();

            var culture = await settingManager.GetSettingValueForUserAsync(
                LocalizationSettingNames.DefaultLanguage,
                abpSession.TenantId,
                abpSession.UserId.Value,
                fallbackToDefault: false
            );

            if (!culture.IsNullOrEmpty())
            {
                return new ProviderCultureResult(culture: (StringSegment)"en-US", uiCulture: culture);
            }

            var result = await GetResultOrNull(httpContext, CookieProvider) ??
                         await GetResultOrNull(httpContext, HeaderProvider);

            if (result == null || !result.Cultures.Any())
            {
                return null;
            }

            //Try to set user's language setting from cookie if available.
            await settingManager.ChangeSettingForUserAsync(
                abpSession.ToUserIdentifier(),
                LocalizationSettingNames.DefaultLanguage,
                result.Cultures.First().Value
            );

            return result;
        }

To force using the culture: (StringSegment)“en-US” in case of Arabic. @ismcagdas

0reactions
FirasKiracommented, May 22, 2019

Ok I’ll try that and back to you with the results.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Who to adjust the Hijri date ? - Apple Community
From here, turn off 'Alternative Calendars'. Next, go to Settings > Language & Region and change your region to Saudi Arabia. After that,...
Read more >
How to Adjust Islamic (Hijri) Calendar Date
How to Adjust Islamic (Hijri) Calendar Date · 1. Click [Settings] on the top right corner of the Today Page. · 2. On...
Read more >
ToLongDateString() showing wrong date in Arabic
When I display the date in the Arabic format CultureInfo("ar-AR") I get an incorrect date from what is entered in the database. My...
Read more >
Hijri Date Problem in Mail Merge MS Access to Word
Hi ,. I created a new project in MS Access 2016 for making appointments of my Patients which contain a Date field for...
Read more >
Hijri Date is displayed in English Numbers
After saving the document and generating the PDF, the numbers are correctly displayed as “Arabic Indic” numbers, while the Hijri Dates like 10/10/1438...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found