I want to change the date picker by upper-casing the first letter of the month.
Currently I'm using the set culture info in the thread and specify the format there, but for my culture the month is always all lowercase:
CultureInfo ci = new CultureInfo("es-MX");
ci.DateTimeFormat.ShortDatePattern = "ddd dd/MMM/yyyy";
Thread.CurrentThread.CurrentCulture = ci;
Displays:
Dom 19/ago/2012
And I would like to have:
Dom 19/Ago/2012
How can I change that?
Specifying the AbbreviatedMonthGenitiveNames
, AbbreviatedMonthNames
along with the ShortDatePattern
did the trick.
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX")
{
DateTimeFormat = new DateTimeFormatInfo
{
AbbreviatedMonthGenitiveNames = new string[] { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", string.Empty },
AbbreviatedMonthNames = new string[] { "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", string.Empty },
ShortDatePattern = "ddd dd/MMM/yyyy"
}
};
Yields:
Edit:
I have to add:
...
AbbreviatedDayNames = new string[] { "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"},
Too
You could probably use the CultureAndRegionInfoBuilder
class to copy the existing culture and change only the month names. Then you subsequently use that culture in your application instead of the CultureInfo
you now use.
Note however, that CultureAndRegionInfoBuilder
is in the sysglobl.dll
assembly, which you'll need to import.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With