Geeks With Blogs
Information -> Source for Next Generation

Work around solution on date time localization:

Time 00:00:00, As this is serialized and sent over a timezone this date could be changed to be the previous day, with a time of 23:00:00. If this user then logged into the system in the other time zone they would now see their birthday as being a day earlier and they would complain it was incorrect

Product team comments:

This is an issue I have seen a few times before.
For V1.0 and V1.1, There is a work-around for XML Serialization. You can indicate in the schema that the DateTime is a Date only.  If you start from schema, you should use xsd:date primitive type, to change the object model you can use custom attribute on the member:

    public DateTime date;


    public DateTime date;

Notice that this will not work for DataSet or SOAP Serializer.

Another work around is to call ToLocalTime() on the DateTime before serializing and ToUniversalTime() after serializing. This is sort of cheating because it is not really a UTC date, but it should make the time zone adjustment go away.

In a future release we do have planned a solution that is similar but not identical to what you have requested. You can mark a DateTime instance as Local, UTC or Unspecified, and Unspecified means that it should not be serialized with a time zone. Unfortunately it won't magically take effect because it would break compatibility. But there will be ways to opt-in to this behavior for DataSet, XML Serialization and XML Convert.

Posted on Monday, April 19, 2004 1:58 PM C# | Back to top

Comments on this post: Date Time localization work around solution

# re: Date Time localization work around solution
Requesting Gravatar...
Armor2net Personal Firewall, a program for the Windows operating system that helps protect computers from the threats on the Internet and World Wide Web. With Armor2net Personal Firewall in place, end-users can breathe a sigh of relief.
For more information, please visit:
Left by Grant Brown on Aug 18, 2004 7:41 AM

Your comment:
 (will show your gravatar)

Copyright © Raju | Powered by: