Re: Web services and incorrect handling of time zones in DateTime



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" <rafal.gwizdala@xxxxxxxxx> schreef in bericht news:1190828534.578423.93800@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: System.TimeZone interface unusable?
    ... ToLocalTime must be "A DateTime instance whose value is the local time ... as the parameter states "a UTC time". ... serializer documentation is the only other place the Kind property is ...
    (microsoft.public.dotnet.framework)
  • Timezone and ISO8601 struggles with datetime and xml.utils.iso8601.parse
    ... I am trying to convert a local time into UTC ISO8601, then parse it ... How can I convert this into UTC? ... the date is converted into UTC on construction of the datetime object, ...
    (comp.lang.python)
  • Re: UTC conversion from different time zones
    ... but in my idea is the time in Net not real calendar based. ... But if you take something which is already UTC (because you've called ... I find the dateTime pretty good. ... DateTime had no idea whether it was a local time or a universal time - ...
    (microsoft.public.dotnet.general)
  • Re: [PATCH] UTC timestamp option for FAT filesystems
    ... It means the timestamp of FAT on the camera is just wrong. ... writing UTC means you modified the design of FAT. ... I do not consider this modifying the design of FAT. ... it's straight local time. ...
    (Linux-Kernel)
  • Re: Time zones dates in vb.net 2005
    ... I have set the region on 1 computer to 'Perth Australia' and the other is on ... Store UTC only. ... know at which local time offset it has been stored. ... you can always use and calculate with the UTC datetime values. ...
    (microsoft.public.dotnet.languages.vb)