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.