dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

Natural culture give wrong ui date format in Windows server 2022/2019 #58564

Open amdnaji opened 2 hours ago

amdnaji commented 2 hours ago

Is there an existing issue for this?

Describe the bug

I have a Razor project and everything was working fine until I decided to upgrade the server from 2016 to 2022 , After upgrading I noticed that .Net accept Hijri date as Gregorian date, for example I have form contain date input filed and If send Hijri date let say (1446/04/19) the .Net will treat this date as Gregorian date not Hijri date. I tried to run the project in different server but this time Windows Server 2016 and i got the expected behavior

Expected Behavior

After configure the localization I tried to print the current Date in the page using DateTime.Now.ToString("yyyy/MM/dd") and instead of printing Hirji date it print Gregorian date which is not the right or expected behavior

Steps To Reproduce

Please clone this Repo and try to run the app in Windows server 2016 and 2022 to see the difference

Image from windows server 2022

Image

Image from windows server 2016

Image

Exceptions (if any)

No response

.NET Version

+6

Anything else?

No response

martincostello commented 1 hour ago

Looks like this issue should be transferred to dotnet/runtime as it doesn't appear to be specific to ASP.NET Core.