N
nightwatch77
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
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