验证特定于语言环境的“习惯";日期格式 [英] Validating Locale-Specific "Customary" Date Formats

查看:125
本文介绍了验证特定于语言环境的“习惯";日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行这段代码...

If I run this code...

var cults = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

var exam = from c in cults
            from p in c.DateTimeFormat.GetAllDateTimePatterns('d')
            select new { Culture = c.DisplayName, Format = p };

...我可以看到Windows或.net认为是不同区域的习惯或标准的各种短日期"格式的转储.

...I can see a dump of the various "short date" formats that Windows or .net thinks is customary or standard for different locales.

但是,谁能独立确认或验证这些值呢?我知道微软已经投入了数十万小时来审核这些日期格式列表.我实际上不认为有任何错误.但是我仍然想知道Microsoft本身是如何执行验证的?他们是否只是阅读了 MLA格式和样式指南的每个特定于语言环境的版本?

But how would anyone independently confirm or verify these values? I recognize that Microsoft has invested possibly many 10's of thousands of hours to vet these date-format lists. I don't actually think there are any errors. But I still want to know how did Microsoft itself perform the validation? Do they simply read every locale-specific rendition of the MLA Formatting and Style Guide?

让我们仔细看一下.根据我在上面编写的代码,以下是美国已知或惯用的短"日期格式的列表:

Let's look at this a bit closer. According to the code I wrote above, below is the list of known or customary "short" date formats for the U.S.:

M/d/yyyy
M/d/yy
MM/dd/yy
MM/dd/yyyy
yy/MM/dd
yyyy-MM-dd
dd-MMM-yy

请注意,格式字符串"dd/MM/yy"不存在.这意味着美国公民不会以"1/8/2014"的形式写2014年8月1日.我同意这一点.然后是日本:

Please notice that the format string "dd/MM/yy" is absent. This implies that U.S. citizens don't write the first of August 2014 in the form "1/8/2014". I would agree with that. Then there is Japan:

yyyy/MM/dd
yy/MM/dd
yy/M/d
yyyy/M/d
yy/MM/dd' ('ddd')'
yy/M/d' ('ddd')'
yyyy/MM/dd' ('ddd')'
yyyy-MM-dd

很明显,该语言环境没有d/M/yy或M/d/yy的习惯用法.知道这很高兴,但是再次...我将如何独立验证.net提供给我的这些选项?

Evidently, that locale has no customary usage of either d/M/yy or M/d/yy. This is great to know, but once again...how would I independently verify these options that .net is presenting to me?

我问的一个原因是因为我正在与全球化工程师讨论,他们不确定他们是否信任.net产生的这些值.如果他们不喜欢Microsoft,那么现在该怎么办"才能说服他们?

One reason I ask is because I am in discussion with globalization engineers who aren't sure if they trust these values that .net produces. If they don't like Microsoft, then "what now" to convince them?

推荐答案

与您的全球化工程师交流时,考虑此问题的最佳方法是Microsoft已在此领域进行了投资,以节省每个开发人员不必重做相同数量的任务.工作.报告问题时将更新此数据,并且如果您确定存在问题,则可以报告它. 通用语言环境数据存储库是类似数据的另一个来源,您也可以针对该数据提交错误.如果他们关心控制,则始终可以选择使用定义为资源的自定义格式格式,以便它们可以随语言而变化.您可以使用Microsoft或CLDR的值预先设置种子.

The best way to think about this when talking with your globalization engineers is that Microsoft has invested in this space to save each developer from having to redo the same amount of work. This data is updated when issues are reported and if you determine that there is an issue, you can report it. The common locale data repository is another source for similar data, and you can file bugs against that as well. If they are concerned about control, you always have the option of using your own custom format patterns that you define as a resource so that they can vary by language. You can pre seed this with values from Microsoft or the CLDR.

这篇关于验证特定于语言环境的“习惯";日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆