为什么es-MX日期格式从Windows 7更改为Windows 10? [英] Why did the es-MX date format change from Windows 7 to Windows 10?
问题描述
这是单元测试:
[TestMethod]
public void Check_how_es_MX_displays_MMM()
{
var originalCulture = Thread.CurrentThread.CurrentCulture;
try
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX");
var result = new DateTime(2015, 8, 6).ToString("MMM");
Assert.AreEqual("ago", result);
}
finally
{
Thread.CurrentThread.CurrentCulture = originalCulture;
}
}
当我在Windows 7上运行它时,它通过了.当我在Windows 10计算机上运行它时,它失败了:
When I run this on Windows 7 it passes. When I run this on a Windows 10 machine it fails:
Assert.AreEqual failed. Expected:<ago>. Actual:<ago.>.
我在两台计算机上都针对.NET 4.5.1进行构建.
I'm building against .NET 4.5.1 on both computers.
在Windows 7和Windows中,"MMM"格式的字符串如何返回"ago".在Widnows 10中?我以为它会给我一个月3个字母的代码.
How could the "MMM" format string return "ago" in Windows 7 and "ago." in Widnows 10? I had assumed it would always give me a 3 letter code for the month.
修改
更多阅读内容表明,使用MMM可以从以下位置查找缩写的月份名称: System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames
Some more reading indicates using MMM makes it look up the abbreviated month name from: System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames
编辑2
这是另一个问题,(我认为)可以解决相同的问题.
Here is another question that deals with (I think) the same issue.
推荐答案
从Windows 10区域设置开始,数据来自 CLDR-常见语言环境数据存储库
Starting with Windows 10 locale data comes from CLDR - Common Locale Data Repository
更多信息: https://博客.msdn.microsoft.com/shawnste/2015/08/29/locale-data-in-windows-10-cldr/
这篇关于为什么es-MX日期格式从Windows 7更改为Windows 10?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!