Over the past 6 years or so, I’ve failed each item on “The Turkey Test.” It’s very simple: will your code work properly on a person’s machine in or around the country of Turkey? Take this simple test.

Parsing dates from a configuration file using DateTime.Parse(string): Does it pass “The Turkey Test?” Nope: Reason: Turkish people write July 4th, 2008 as “04.07.2008” Fix: Always specify what format your date is in. In this case, we use a DateTimeFormat.InvariantInfo which just happens to be USA English’s format (more or less): Which gives us what we were expecting: Scott Hanselman likes to talk about DateTimes. (Be sure to see his DateTime interview question).

Ok, ok. You knew about dates. I sort of did, but I still got it wrong the first few times. What about this seemingly simple piece of code: Does it pass “The Turkey Test?” Nope: Reason: Turkish people use a period to group digits (like people in the USA use a comma). Instead of getting a 4.5% discount like you intended, Turkish people will be getting at 45% discount. Fix: Again, always specify your format explicitly: Which saves your company from having to go out of business from having too high of discounts: