5

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?

Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
OscarRyz
  • 196,001
  • 113
  • 385
  • 569

2 Answers2

5

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:

enter image description here

Edit:

I have to add:

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

Too

OscarRyz
  • 196,001
  • 113
  • 385
  • 569
2

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.

Community
  • 1
  • 1
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
  • Didn't need ( couldn't ) use that class, but instead I specify the `AbbreviatedMonthNames` property – OscarRyz Aug 19 '12 at 18:07