I have the following code:
public static void Main(string[] args)
{
var dateTime = DateTimeHelper
.ConvertPersianDateTime("12/22/1402", "09:33:12")
.ToString("D");
Console.WriteLine(dateTime);
}
public static DateTime ConvertPersianDateTime(string persianDate, string persianTime)
{
var isParse = DateTime.TryParse($"{persianDate} {persianTime}",
new CultureInfo("fa-IR"),
DateTimeStyles.None, out var result);
return isParse ? result : DateTime.Now;
}
When I run the program in ubuntu server, I get this result:
Tuesday, March 12, 2024
But when I run the program in centos server, I get this result:
Wednesday, December 22, 1402
Why result of centos server is different with ubuntu?
I think this is related with this Github issue.
Also from this supported distributions page;
So, this looks like a ICU problem rather than a .NET problem. You can always file an issue for that but remember Centos 8 is not supporting OS any more for .NET development.
Update:
By adding
PersianCalendartoCultureInfoproblem will fix: