Validating Locale-Specific “Customary” Date Formats

有些话、适合烂在心里 提交于 2020-01-17 03:59:18

问题


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 };

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

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

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

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?

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?


回答1:


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.



来源:https://stackoverflow.com/questions/26749555/validating-locale-specific-customary-date-formats

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!