The blog of Eric Sibly; focusing on mountain biking, .NET development for the Desktop, Smartphone and PocketPC.

Monday, April 11, 2005

Issues with Serializing DateTime...

It must be my once a year issue - weird. Over a year ago I was on a project and we were having all sorts of problems with the serialization of the DateTime data type; especially where we were not interested in the time portion. Because of time zone changes the date would end up being changed on the server as the time was never updated from 00:00:00 as it was considered irrelevant – but is included within the serialized value. Consider your birthday for example - you're never generally asked for the time when entering on a form and it should be time agnostic – you would celebrate it on when the day it fell in, whatever time zone you are currently residing.

So most would use a DateTime and ignore the time, so it would be "1970-01-22 00:00:00", but the serializer adds an offset for the timezone, say "+10". Now, along come daylight savings or timezone change, and it gets refactored to "+9", now I am born on "1970-01-21 23:00:00" - What the?

About a year ago (to the day) I send a note to BradA from Microsoft (my original question is included as the “reader asks”), and this is his reply plus a bunch of other comments left that may be of interest.

So today, I called into a different project that was having issues with timezones. So it was back discussing the cons of the DateTime serialization under .NET 1.x, and some basic workarounds.

There has been talk of changes/fixes in .NET 2.0 for this; however, I have not been able to find anything tangible on the subject :-( Update: Just found this, although it still doesn't sound like a great story.

0 Comments:

Post a Comment

<< Home