locked
WCF Data Services/SQL Server/DateTime across multiple time zones RRS feed

  • Question

  •  I have a Silverlight application that has the potential to be used across multiple timezones.  For this reason, I want to have any datetime stored in the SQL server as UTC.  The various DomainServices also need to work in UTC since they need not be in the same timezone as the client. But on the client I want local time to be displayed (at least most of the time, if the user wants to view a time in a timezone outside of her local timezone I need to be able to do that also).

    As I understand it, the  most appropriate way to do this is to use a DateTime on the SQL server which is not timezone aware and make the design declaration that it is UTC.  I have done this in the past. I am quite familiar with using the TimeZone object to convert to/from UTC.  It appears that the default behavior of WCF RIA Services is to have the .Net DateTime in the SL client be marked as .Kind=Unspecified.  In essence, on the client you have (by default) UTC displayed and acted upon.

    Is there any guidance for using WCF Data Services and entities that include DateTime with localization to timezones?  Obviously, I can always add an additional entry to entities for each datetime field and calculate the proper display on client side, but it would seem that this is a common enough event that I would hope that there is some pattern implemented.

    Tuesday, May 18, 2010 11:44 AM

Answers