March 2008 - Posts

Our daily link (2008-03-13)

Sorry about the lack of categories yesterday. I was really lazy.

Web

Career stuff

Blogging

Misc

Posted by trumpi | 1 comment(s)

Is CultureInfo.InvariantCulture variant?

My mother always used to teach me to write date parsing code that passes the Turkey Test. So to parse a date from a configuration file, the following snippet is used:

        DateTime timeOverride;
        bool res = DateTime.TryParseExact("27/03/2008 12:30:00", 
            "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, 
            DateTimeStyles.None, out timeOverride);
        Assert.IsTrue(res);

This works great! It always parses the date as 27 March 2008 and res is true.

Except on one particular machine. On this rogue machine TryParseExact always returns false.

Any ideas? We're looking like fools because it doesn't work on one machine.

Posted by trumpi | 4 comment(s)