.NET 和 Windows 不同于标准的文化
.NET and Windows Cultures different from standards
如果我运行下面的C#代码
var cultureInfo = new System.Globalization.CultureInfo("af");
Console.WriteLine(cultureInfo.DateTimeFormat.ShortDatePattern);
我得到了 yyyy-MM-dd 的输出。
但是如果我在客户端使用 momentjs 并且运行下面的代码
var localeData = moment.localeData('af');
console.log(localeData._config.longDateFormat.L);
我得到 DD/MM/YYYY 的输出。
它们为什么不同?研究表明 momentjs 可能是正确的。如果我在客户端输入一个日期,然后尝试在服务器上解析它,就会出现问题。
var cultureInfo = new System.Globalization.CultureInfo("af");
等于
af-ZA Afrikaans - South Africa 0x0436 AFK
Date and time notation in South Africa
South Africa signed up to use ISO 8601 for date and time
representation through national standard ARP 010:1989 in 1998. The
most recent South African Bureau of Standards standard SANS 8601:2009
"... is the identical implementation of ISO 8601:2004, and is adopted
with the permission of the International Organization for
Standardization" and was reviewed in 2016.
日期备注
Even so, the old date format is still commonly used in the format
"dd/mm/yyyy", with the "day month year" order being more common with
non-numeric month designations.
https://en.wikipedia.org/wiki/ISO_8601
YYYY-MM-DD or YYYYMMDD
.NET Framework Cultures with Date and Time String Formats
English Name Abbreviation ShortDate Format
Afrikaans (South Africa) af-ZA yyyy/MM/dd
老实说 : momentjs
似乎是错误的
如果我运行下面的C#代码
var cultureInfo = new System.Globalization.CultureInfo("af");
Console.WriteLine(cultureInfo.DateTimeFormat.ShortDatePattern);
我得到了 yyyy-MM-dd 的输出。
但是如果我在客户端使用 momentjs 并且运行下面的代码
var localeData = moment.localeData('af');
console.log(localeData._config.longDateFormat.L);
我得到 DD/MM/YYYY 的输出。
它们为什么不同?研究表明 momentjs 可能是正确的。如果我在客户端输入一个日期,然后尝试在服务器上解析它,就会出现问题。
var cultureInfo = new System.Globalization.CultureInfo("af");
等于
af-ZA Afrikaans - South Africa 0x0436 AFK
Date and time notation in South Africa
South Africa signed up to use ISO 8601 for date and time representation through national standard ARP 010:1989 in 1998. The most recent South African Bureau of Standards standard SANS 8601:2009 "... is the identical implementation of ISO 8601:2004, and is adopted with the permission of the International Organization for Standardization" and was reviewed in 2016.
日期备注
Even so, the old date format is still commonly used in the format "dd/mm/yyyy", with the "day month year" order being more common with non-numeric month designations.
https://en.wikipedia.org/wiki/ISO_8601
YYYY-MM-DD or YYYYMMDD
.NET Framework Cultures with Date and Time String Formats
English Name Abbreviation ShortDate Format
Afrikaans (South Africa) af-ZA yyyy/MM/dd
老实说 : momentjs
似乎是错误的