Dan Byström’s Bwain

Blog without an interesting name

Archive for February, 2004

Date format blues

Posted by Dan Byström on February 5, 2004

How much time do we spend converting between different date formats? I probably don’t want to know.

Right now I was reading from a file containing dates like this: 1/12/2004. On my system, using Date.Parse(strDate) in .NET translates this to December 01, although it is obvious from the context that it means January 12! Now it turns out that it is easy to fix this by using:

    Date.Parse(strDate, New System.Globalization.CultureInfo("en-GB", True))

But still I wonder, is it so hard to use the ISO 8601:1998 format instead: yyyy-mm-dd??? This is the ONLY logical way to express a date, since it is POSITIONAL!

We use a positional system to write numbers, like 479 instead of CDLXXIX beacuse it is easier to work with! (How to you multiply CCXXIV with DLVII?) Dates given in ISO 8601:1998, among other things, sort correctly using normal string sorting routines. This reminds me of KB Q170884, which describes a hard-core way to get a ListView to sort dates correctly, but fails to mention that if dates were given in the only logical way to express dates, the ListView sorts correctly by default. Amazing!

Posted in Programming | Leave a Comment »