Friday, July 08, 2005

It is funny the things you learn from searches. Today I learned that System.DateTime is not based in UTC. In fact it is based in TAI, which is the real "atomic" time without leap-seconds.
Now I realize most people don't know or care about the difference, but I have an obsession with dates, times and all things chronological. Here are a few of my favorite tidbits:

Developing Time-Oriented Database Applications in SQL by Richard T. Snodgrass is a wonderful book about doing proper SQL database designs and queries when the chronology of data points, the posting of them, or the subsequent view "in time" of data is important. This area is extremely difficult to get right consistently and this book walks you through the evolution of several real world systems to get it right as the needs are evolved. It is out of print, but you can download the book in PDF form here.

Coding Best Practices Using DateTime in the .NET Framework
Dan Rogers MSDN article. This is a great place to start, as it addresses most of the issues you will likely run into.

New DateTime Best Practices Article BCL Team Article. This is a very good summary of the issues you can run into and how to deal with them.

Representing Null DateTime values in code Scott Munro blog talks about how nulls in dates can be handled, lots of excellent links. I personally use the Null Object pattern with DateTime.MinValue representing start dates and DateTime.MaxValue representing end dates.