Craig
Craig

Reputation: 36836

.NET and Windows Cultures different from standards

If I run the following C# code

var cultureInfo = new System.Globalization.CultureInfo("af");       
Console.WriteLine(cultureInfo.DateTimeFormat.ShortDatePattern);

I get the output of yyyy-MM-dd.

However if I use momentjs on the client and run the following code

var localeData = moment.localeData('af');
console.log(localeData._config.longDateFormat.L);

I get output of DD/MM/YYYY.

Why are they different? Research indicates the momentjs one is probably right. This is a problem if I enter a date in the client and then try and parse it on the server.

Upvotes: 3

Views: 131

Answers (1)

TheGeneral
TheGeneral

Reputation: 81513

var cultureInfo = new System.Globalization.CultureInfo("af");  

Which equates to

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.

Date Remark

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  

In all honesty : momentjs seems wrong

Upvotes: 3

Related Questions