I live in the Dominican Republic and have been developing applications using the .NET Framework for a couple of years. Usually, I create localized applications for this specific culture (es-DO
) and it's very helpful for me to use the built-in .NET globalization mechanism. In the case of a web application, I usually define the global culture in the Web.Config:
<globalization culture="es-DO" uiCulture="es-DO" />
But there's an issue in the ShortDatePattern
of the DateTimeFormat
for that culture that has caused confusion for me and fellow developers. For unknown reasons, the default ShortDatePattern
format is d/M/yy
while in reality the regular formats used in this country are dd/MM/yyyy
and dd-MM-yyyy
like most other Spanish-speaking countries (which are, by the way, configured correctly).
I created a small console application to illustrate better:
I have confirmed the same behavior in several PCs and even publishing my web apps to hosting providers like Windows Azure.
I have been looking for information on the subject, but it seems like it's a very localized issue regarding this specific (and not-so-popular I may add) culture and therefore it's very hard to find any documentation at all.
Basically, I have two questions regarding this:
EDIT
This has now been reported as a bug in Microsoft Connect and Visual Studio Forums.
.Net gets its data from Windows (at least it has since .Net 4.0 -- and even in prior versions the only difference is in the final default data). The short date pattern is returned by a call to GetLocaleInfoEx with the LCTYPE of LOCALE_SSHORTDATE.
The process for returning the appropriate data is effectively (there are optimizations in place) to check to see if the locale name requested (in your case "es-DO") is the current user locale and if so to check and see if there is a user requested override for that value. If there is then it is returned, if not, then if there is a custom culture installed that replaces the default data, that data is returned. Finally, the default supplied data is returned.
The default data is part of an internal database that is maintained by Microsoft. That database has been maintained for ages and periodically reviewed by in country language experts. If you see something that doesn't seem right and you are a native speaker, you should report it as a bug. Sometimes there are legitimately more than one way to express the data and the speakers themselves are split as to which is the "right" one. That is why users can override the defaults for the user locale.
There are a couple of options for working around this:
If you choose to do the last, you will want to look at the DateTimeFormatInfo.GetAllDateTimePatterns method. Use the 'd' format to get all the short date formats and then you can find the first one containing "yyyy".