468,535 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,535 developers. It's quick & easy.

Web services and incorrect handling of time zones in DateTime

Hi, does anyone know why .Net incorrectly handles time zone conversion
when passing DateTime through web services? The problem is that it
seems to ignore the time zone part. My time zone is CEST, that is GMT
+01:00 + daylight saving. And the web service handles datetimes
correctly provided that they are also in CEST. But when some client
calls my web service passing dates in UTC, the .Net runtime just
ignores that fact and takes just the date & time portion literally.
So for example, when the SOAP message contains datetime like
<SomeDate>2007-09-26T10:00:00+01:00</SomeDate>, the date is received
correctly - it is 10:00 local time.
But when the date is <SomeDate>2007-09-26T09:00Z</SomeDate(which is
exactly the same time as previously, but in UTC), it becomes DateTime
2007-09-26 09:00:00 (in local time also) which is just incorrect.
Logically thinking, the UTC time should be converted to local time
because it is clear that it is passed as UTC and needs to be adjusted
to local time. DateTime structure does not contain time zone
information, so I'm unable to tell whether the web service client has
specified the date in UTC, or local time, or whatewer time zone it had
- therefore it's not possible to correct this error 'manually' - I
would have to mess with SOAP serialization to handle that.
Is this by design (very poor design in my opinion) or an error?

Best regards
RG

Sep 26 '07 #1
2 4863
Rafal,

You are not the first one writing this, I think that it is an error by
design.

I have no idea if this is fixed in newer versions.

Cor

"nightwatch77" <ra************@gmail.comschreef in bericht
news:11*********************@k79g2000hse.googlegro ups.com...
Hi, does anyone know why .Net incorrectly handles time zone conversion
when passing DateTime through web services? The problem is that it
seems to ignore the time zone part. My time zone is CEST, that is GMT
+01:00 + daylight saving. And the web service handles datetimes
correctly provided that they are also in CEST. But when some client
calls my web service passing dates in UTC, the .Net runtime just
ignores that fact and takes just the date & time portion literally.
So for example, when the SOAP message contains datetime like
<SomeDate>2007-09-26T10:00:00+01:00</SomeDate>, the date is received
correctly - it is 10:00 local time.
But when the date is <SomeDate>2007-09-26T09:00Z</SomeDate(which is
exactly the same time as previously, but in UTC), it becomes DateTime
2007-09-26 09:00:00 (in local time also) which is just incorrect.
Logically thinking, the UTC time should be converted to local time
because it is clear that it is passed as UTC and needs to be adjusted
to local time. DateTime structure does not contain time zone
information, so I'm unable to tell whether the web service client has
specified the date in UTC, or local time, or whatewer time zone it had
- therefore it's not possible to correct this error 'manually' - I
would have to mess with SOAP serialization to handle that.
Is this by design (very poor design in my opinion) or an error?

Best regards
RG
Sep 27 '07 #2
OK, I have found some information on this error, but no feasible
solution.
Is it possible to correct that without putting any additional
requirements on web service clients?

RG

Sep 27 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gerrit Holl | last post: by
3 posts views Thread by Jon Davis | last post: by
9 posts views Thread by Phil B | last post: by
3 posts views Thread by Curtis | last post: by
4 posts views Thread by Maziar Aflatoun | last post: by
3 posts views Thread by Satish Itty | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.