473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 5055
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
3
by: Curtis | last post by:
I am trying to convert a string to datetime format and I get an invalid Date/Time format error. The code I am trying to use is: msgtime = CDate("Sat, Aug 27 2005 20:00:00 EDT") I know I can...
4
by: Maziar Aflatoun | last post by:
Hi, Can someone please tell me how I can set DateTime to 01/01/1970 (UTC). Doing the following DateTime dt1 = new DateTime(1970, 1,1); Debug.WriteLine("dt1(utc):"+...
7
by: Dick | last post by:
I have a long list of events. I know where each event took place (globally) and when (using the event’s local time). I want to do some comparisons between these date/times. I thought I would...
3
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a...
4
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is...
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.