Gray's Matter
Justice Gray - North America's Favorite Metrosexual Software Consultant
globe.gif

I thought I would continue my seeming tradition of hitting these questions once every 6 months.   Actually, I had given up on Granny getting into Corillian but that's okay; she's seen the light and is now an independent consultant!  Nonetheless, I have still felt the need to answer some of Scott Hanselman's old interview questions in an attempt to help get her up to speed.

So, without further adieu, let's tell two stories about marriages:

Story #1:

My sister-in-law is getting married this coming May.  I had a chance to meet her future husband's parents this past Christmas, both of whom are from Quebec and primarily speak French.  As is my custom when I am meeting new people, I tried to amp up the patented Justice Gray charm ™ and impress them with the French I vaguely remembered from about a decade and a half ago.  I introduced myself ("Je m'appelle Justice") and then decided to follow up with the coup de grace: terrifically witty banter.  

"The French I am speaking now is the only French I know!"


I paused for laughter - but instead was met with nervous silence!!  In this moment, I finally learned what Donald goes through at the beginning of every EDMUG meeting.

I was definitely a little confused; after all that sentence should have been a guaranteed laugh riot.  My future brother-in-law came up to me and quietly whispered,
"I think I understood what you were saying, but my parents actually think you have some sort of handicap now"

It seems instead of my intended phrase, I had stated something closer to

"I speak French.  French speak!!  Only French!!  I know speak!!!"

Fortunately, I solved the awkwardness that night like anyone would: by getting *completely hammered*.

Speaking of solving all of the world's problems through excessive alcohol consumption , let's go onto story #2.

As most of you know, I was married a year and a half ago.  What many of you don't know is that one of my groomsmen, flush with alcohol and ready to try and impress the ladies, decided to go to one of the bridesmaids and show off his *fluent* knowledge of Cantonese.  Whatever his planned come-on line was will forever remain a mystery.  I wish I could say the same for the translation of what he *did* say, which was, "Boy, I'd really like to sleep with your mother."  

So, what's the problem here?  Lost or unclear intent through translation, or lack thereof.  This is also the difficulty Scott Hanselman was referring to when he asked

"What’s wrong with a line like this? DateTime.Parse(myString);"


This line on its own seems pretty simple - after all, you're just asking for the runtime to take a standard string and convert it into a DateTime object.  

DateTime myDate = DateTime.Parse("10/06/2006");

What's the value for myDate.Month and myDate.Day?

And therein lies the problem: there is no way for you to tell me this without knowing additional information.

For example, if I am running this with an English culture, the DateTime object represents October 6, 2006.  However, if I ran this same line on a computer with its culture set to French (or if the application's culture was set to French), then the DateTime object now represents a completely different date (June 10, 2006, to be precise).  This happens because French dates reverse the position of the month and the day.  

To get around this, always pass Culture information as the second argument to DateTime.Parse, as in the following:

DateTime myDate = DateTime.Parse("10/06/2006", System.Globalization.CultureInfo.GetCulture("fr-FR"));

Now, obviously you wouldn't want to do a culture retrieval every single time you call DAteTime.Parse!  Your application should probably be setting the culture itself, somewhat like the following

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR");
DateTime myDate = DateTime.Parse("10/06/2006", System.Globalization.CultureInfo.CurrentCulture)


This sets the culture for the particular thread of execution that your current user is experiencing.  

You might not think that globalization errors are as embarassing as the two stories I talked about earlier.  Trust me, in the context of a globalized application, they are even worse.  Take this tip and use it to save yourself humiliation in code reviews everywhere!

Previous entries in this series:
My grandmother and the Global Assembly Cache (and Star Wars)
My grandmother and the difference between processes and threads
My grandmother and the difference between HTTP GET and HTTP POST

Comments

Good post, honey!  I actually laughed out loud this time! ;)

And wasn't our groomsman saying that about *my* mother, no less?  Proof that alcohol can rot even the smartest brain!

Reply

I thought you laugh out loud at every post I make?!?!

MY LIFE IS A LIE

Reply

Tom Opgenorth

Dude, what's up?  A technical post?  I was expecting to read something about Transformers or Macs.

Reply

Well, every so often I need to take a break from the Mac/Transformer thing, though I love it a lot.  Don't worry, I'll try not to post anything technical for another 6 months ;)

Reply

JH

Thanks for this post Justice! Today I used this to illustrate to a developer why just having something like the XmlSerializer deserialize a DateTime without declaring the culture was a bad idea (especially since the agreed upon date format was NOT the same as the default culture of the machine we were testing on).

Reply

#6 anonymous  on 3/27/2007 2:37:19 PM

anonymous

when you said "Je m'appelle Justice"
How did you pronounce Justice?
In its English way, or French sexy way?

Reply

Vladimir Levin

I wonder if it wouldn't be better to actually specify the format of the date along with the date itself...

Reply

Keith Rull

Hahaha! nice ;)

Reply

WHO CARES WHAT YOU THINK VLAD

*ahem* ;)

Actually, you are quite correct depending on the situation.  =)  I will have to edit the post after to add that in.

Reply

Anonymous - no matter what method or language in which I say "Justice", it's *always* a sexy way. ;)

Reply

#11 Haiyan  on 3/28/2007 5:39:11 PM

Haiyan

lol.
I think I know what that guy said.
Ok, I better go back and finish this tech article.

Reply

Brent

Absolutely brilliant.   This is a great way to make your point.

Reply

Marriage Counselor

I believe that finding a good husband is a tedious task but not an impossible one.

Reply

ordering original butalbital

discount lowest cost butalbital

Reply

Generic tramadol information

Tramadol Us

Reply

Alcohol Treatment

Your stories are very funny. I had a good laugh reading them and I have to tell you that you could always be hired for a comedy show so get ready because you never know what life has prepared for you...

Reply

six figures yearly

I'm happy to hear that your sister is getting married. A friend of mine is going to do the same thing in the next future and I've heard that she is going to have a double marriage with a friend of her's. Isn't it your sister? That would be absolutely great! Please let me know if your sister is going to do the same thing and if so, when. Thank you!

Reply

tramadol online

Your story was very intriguing. Keep writing more amazing pieces

Reply

Really interesting post. Keep it up!

Reply

trackback

My grandmother and the difference between processes and threads

My grandmother and the difference between processes and threads

Reply

online gambling

The stories that you shared are hilarious! I especially liked the one about your groomsman. I would have been completely mortified I was in his shoes!

Reply

Add comment


(will not be published)

  Country flag

biuquote
  • Comment
  • Preview
Loading