Localizing DateTime value

Localizing DateTime value

Old forum URL: forums.lhotka.net/forums/t/688.aspx


Mark posted on Thursday, July 20, 2006

I have a database that will be updated/replicated across 4 different time zones.  There are a few fields that I keep (DateCreated, LastModified, etc) - that I need to keep in sync across time zones.

Storing in UT/GMT/Zulu time (or whatever it's called now) is the obvious solution.  What isn't so obvious is how/where to do the conversion, since I want the users to see the time represented in their respective time zones.

My first thought is to decode the value to the local time zone during the fetch, and to reconvert it to Zulu during any inserts/updates.  This seems to be the simplest solution with the least code impact.  Just seems a tad inappropriate having the object handle what's basically a UI issue, though.

Have any of you had to deal with this, and if so, what was your approach?

RRorije replied on Friday, July 21, 2006

I see your point  and I have not dealt with it, but IMHO this is not a UI issue. It sounds to me the same as creating a property on a businessobject that combines first name and lastname to fullname. Which in my opinion should also reside on the businessobject.

I think you just have to add a readonly property to the businessobject that represents local time, based on the DateCreated/ LastModified. This can be done during Fetch, or just when adressing the property.


RockfordLhotka replied on Friday, July 21, 2006

It seems to me that Brad Abrams (a key guy on the .NET Framework team) blogged about this sort of thing a year or two ago. I don't have time to google it for you - but he (or someone on his team) did write a really nice article about formatting datetime values for time zones.

And as I recall, not all the answers were pretty... Sad [:(]

Copyright (c) Marimer LLC