I’m having a weird validation failure in a ASP.NET MVC 3 site with a textbox that accepts a datetime choosen via jqueryui. The site has been customized to work only with es-ES culture and works most of the time but the validation fails everytime certain month is used in that textbox. The datetime.parse method works for every month except march:
DateTime.Parse("15-feb-2012",CultureInfo.GetCultureInfo("es"), DateTimeStyles.None)
{15/02/2012 0:00:00}
Date: {15/02/2012 0:00:00}
DateTime.Parse("15-ene-2012",CultureInfo.GetCultureInfo("es"), DateTimeStyles.None)
{15/01/2012 0:00:00}
Date: {15/01/2012 0:00:00}
DateTime.Parse("15-abr-2012",CultureInfo.GetCultureInfo("es"), DateTimeStyles.None)
{15/04/2012 0:00:00}
Date: {15/04/2012 0:00:00}
…
every month works except March , Marzo in Spanish …
DateTime.Parse("15-mar-2012",CultureInfo.GetCultureInfo("es"), DateTimeStyles.None)
DateTime.Parse("15-mar-2012",CultureInfo.GetCultureInfo("es"), DateTimeStyles.None)' threw an exception of type 'System.FormatException'
base {System.SystemException}: {"String was not recognized as a valid DateTime."}
Any idea?
Reproducing with NUnit:
Try setting the format and this works: