CultureInfo instances (from the same culture) are modified based on the OS

I have a website that writes a date like this:

CultureInfo cultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(c => string.Equals(c.TwoLetterISOLanguageName, MvcApplication.Language));
return string.Concat(date.Day, ".", cultureInfo.DateTimeFormat.GetAbbreviatedMonthName(date.Month));

On my PC (Windows 7, Service Pack 1, the Spanish culture) and on the server (Windows Server 2012 English culture) MvcApplication.Languagethere es, so the culture that I get from the list: es-ES.

I would expect both of them to write the same line (they have different cultures, but I do not use CurrentCulture). However, the results are abron my PC and Abr.on the server.

I tried this isolated from MvcApplication.Languageusing LinqPAD , but it is still different. I printed arrays AbbreviatedDayNamesand AbbreviatedMonthNames, and they are different on each computer.

Am I doing something wrong or is this the expected behavior? How can I make this completely independent of Windows / User Culture?

+5
source share
1 answer

And you can see this link from MSDN, cultural information may vary in some versions of Windows.

, , . Windows- . , CultureAndRegionInfoBuilder. Microsoft Locale Builder. Microsoft Locale Builder CultureAndRegionInfoBuilder.

, - , CultureInfo , ,

+1

All Articles