Change text selection date: write down month

I want to change the date picker to the uppercase of the first letter of the month.

Currently, I use the given culture information in the stream and specify the format there, but for my culture, the month always has all lowercase letters:

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:

Dom 19 / ago / 2012

How to change this?

+5
source share
2 answers

Indication AbbreviatedMonthGenitiveNames, AbbreviatedMonthNamesalong with ShortDatePatternperformed 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"
    }
};

Productivity:

enter image description here

Edit:

I need to add:

...
AbbreviatedDayNames = new string[] { "Dom",  "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"},

Too

+5
source

Perhaps you can use the CultureAndRegionInfoBuilderclass to copy an existing culture and change only the names of the months. Then you then use this culture in your application instead of the one you use CultureInfo.

, CultureAndRegionInfoBuilder sysglobl.dll, .

+2

All Articles