Same TimeZone on Client as Server on specific data table columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

We are sending DataSets over web service. This is a world wide used
application, with web service consumers in different TimeZones.

The inbuilt .NET functionality that automaticly recalculate (based on
TimeZone difference) the values in Date-columns are nice for us in most cases.

Now we have identified a few data table columns, that should not be
recalculated on client - we want to show same date and time that is stored in
database. (I am not going to waste effort on explaining why.)

Of course I understand that one solution is that each time these value are
substracted/displayed from the data set, I manually add or subtract the time
difference and display it to user. This is very bad solution I think. I want
to make some more general setting on that column (or on all values in that
column) so that when this is done I do not have to think about any more. I
mean that then all data displayed from this column is transparantly shown
with server TimeZone.

Best regards,
Benjamin, Sweden
 
Hi

Based on my research, this is a limitation.

Further, it turns out that forcing the System.XML.Serialization serializer
to encode a date value in GMT on the wire is not possible in .NET, at least
not today.

The Special Case of XML
Several people I've talked to recently had the design goal of serializing
time values over Web services such that the XML that represents the
DateTime would be formatted in GMT (e.g., with a zero offset). While I've
heard various reasons ranging from the desire to simply parse the field as
a text string for display in a client to wanting to preserve the "stored in
UCT" assumptions that exist on the server to the callers of Web services,
I've not been convinced that there is ever a good reason to control the
marshalling format on the wire to this degree. Why? Simply because the XML
encoding for a DateTime type is perfectly adequate for representing an
instant in time, and the XML serializer that is built into the .NET
Framework does a fine job of managing the serialization and deserialization
issues associated with time values.

Further, it turns out that forcing the System.XML.Serialization serializer
to encode a date value in GMT on the wire is not possible in .NET, at least
not today. As a programmer, designer, or project manager, your job then
becomes making sure that the data that is being passed in your application
is performed accurately with a minimum of cost.

Several of the groups I talked with in the research that went into this
paper had adopted the strategy of defining special classes and writing
their own XML serializers so that they have full control over what the
DateTime values on the wire looked like in their XML. While I admire the
pluck that developers have when making the leap into this brave
undertaking, rest assured that the nuances of dealing with daylight savings
time and time zone conversion issues alone should make a good manager say,
"No way," especially when the mechanisms provided in the .NET Framework do
a perfectly accurate job of serializing time values already.

There is only one trick you have to be aware of, and as a designer you MUST
understand this and adhere to the rule (see Rule #5).

Coding Best Practices Using DateTime in the .NET Framework
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/datetimecode.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi!

We see no manageble way to work with DateTime format, in our case.
We are going to convert the database column to string,
and send strings over web services and present strings in clients.

Thanks anyway.

Benjamin,
Sweden
 
Hi

Yes, so far this is a limitation, that the XML serializer will do the
datetime convert on which webservice is based.
So far, the workaround to that, is to define that column as a string
column, so that the xml serializer will consider it as a common string.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Now almost a year later, I would like to know if there are some news about
this (i e disabling time zone adjustment when sending data sets over web
services)in .NET Framework 2.0.
 
Back
Top