--- DateTime.cpp	23 Mar 2005 15:45:00 -0000	1.16
+++ DateTime.cpp	7 Apr 2005 04:15:03 -0000
@@ -184,6 +184,7 @@
 	    AxisChar *cTemp;
 	    AxisChar *cTemp2;
 	    AxisChar *cTemp3;
+        bool hasTZInfo = false;
 
         // Calculate local timezone offset
         time_t now = 0;
@@ -233,46 +234,31 @@
         value.tm_zone = NULL;
         value.tm_gmtoff = -1;
 #endif
+        time_t timeInSecs = mktime (&value);
+        if (timeInSecs == -1)
+        {
+            throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+        }
+        pTm = localtime (&timeInSecs);
+
         cTemp2 = const_cast<char*>(strpbrk (valueAsChar, "T"));
-        cTemp3 = strrchr (cTemp2, ':');
-        cTemp3[0] = '\0';
         unsigned int len = strlen (cTemp2);
-        cTemp3[0] = ':';
 
         /*if the timezone is represented adding 'Z' at the end */
         if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
         {
-            time_t tempmktime = mktime (&value); // convert tm object to seconds
-            if (tempmktime == -1)
-            {
-            	throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
-            }
-            pTm = localtime (&tempmktime); // construct tm object from seconds
-            memcpy (&value, pTm, sizeof (tm));
-            time_t t = mktime (&value);
-            if (t == -1)
-            {
-              throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
-            }
-
-            t = labs (t - d);
-            pTm = localtime (&t);
+            hasTZInfo = true;
         }
         /*if the timezone is represented using +/-hh:mm format */
         else if (len > (sizeof (char) * 6))
         {
+            hasTZInfo = true;
             cUtc = strpbrk (cTemp2, "+");
             if (cUtc == NULL)
             {
                 cUtc = strpbrk (cTemp2, "-");
             }
-            
-            time_t timeInSecs = mktime (&value);
-            if (timeInSecs == -1)
-            {
-            	throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
-            }
-            
+           
             int hours = 0;
             int minutes = 0;
 
@@ -282,35 +268,24 @@
             }
 
             int secs = hours * 60 * 60 + minutes * 60;
+            /* Normalize transmitted local time to UTC */
             if ((cTemp = strpbrk ((cUtc), "+")) != NULL)
             {
-                timeInSecs += secs;
-            }
-            else
-            {
                 timeInSecs -= secs;
             }
-
-            pTm = localtime (&timeInSecs);
-            memcpy (&value, pTm, sizeof (tm));
-            time_t t = mktime (&value);
-            if (t == -1)
+            else
             {
-            	throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+                timeInSecs += secs;
             }
-
-            t = labs (t - d);
-            pTm = localtime (&t);
         }
-        /*if the zone is not represented in the date */
-        else
+
+        if (hasTZInfo)
         {
-            /*else it is assumed that the sent time is localtime */
-            time_t timeInSecs = mktime (&value);
-            if (timeInSecs == -1)
-            {
-		    	throw AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
-            }
+            /* Account for daylight savings */
+            if (pTm->tm_isdst != 0) d -= 3600;
+
+            /* Now compute our local time from the UTC time we computed above */
+            timeInSecs = labs (timeInSecs - d);
             pTm = localtime (&timeInSecs);
         }
