Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anthony Candaele 1197 posts 2049 karma points
    Jan 12, 2013 @ 11:29
    Anthony Candaele
    0

    date parsing error after upgrade 4.7.2 > 4.11.2.2

    Hi Guys,

    After upgrading my Umbraco site from version 4.7.2 to 4.11.2.2 this line of code throws an error:

    jobnode.getProperty("jobStartsAt").Value = DateTime.Parse(datepicker.Text, provider);

    It work fine before. After upgrading the umbraco.dll, cms.dll, businesslogic.dll I get this error when the above line of code is executed:

    anyone has a clue what could be the problem?

    your help is appreciated,

    Anthony

  • Anthony Candaele 1197 posts 2049 karma points
    Jan 12, 2013 @ 12:05
    Anthony Candaele
    0

    got some further insight in this. Apparently it's caused by the en-Us dateformat (mm/dd/yyyy).

    The error is thrown when I pick a  date like 26th march 2013. Apparently 26/03/1013 is not recognized as a valid en-Us date.

    Therefore I declared a variable holding the Culture info:

    private CultureInfo provider = CultureInfo.GetCultureInfo(CultureInfo.CurrentCulture.Name);

    then I pass the provider parameter to the Datetime.Parse() method like this:

    jobnode.getProperty("jobStartsAt").Value = DateTime.Parse(datepicker.Text, provider);

    This works fine on the server, where I have an English version of sql server.

    It throws an error however on my local development machine where apparently I have another language version of sql server.

    So the only way I can prevent a FormatException being thrown on my development machine is by testing with dates where month and day are interchangeable (like 3/5/2012, 6/7/2013 etc ...)

    It's not a huge problem, but a bit annoying.

    Wondering if there is a better solution for this.

    greetings,

    Anthony

Please Sign in or register to post replies

Write your reply to:

Draft