You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/02/10 15:11:42 UTC

cvs commit: ws-axis/c/src/soap/xsd Date.cpp DateTime.cpp GDay.cpp GMonth.cpp GMonthDay.cpp GYear.cpp GYearMonth.cpp Time.cpp

dicka       2005/02/10 06:11:42

  Modified:    c/src/soap/xsd Date.cpp DateTime.cpp GDay.cpp GMonth.cpp
                        GMonthDay.cpp GYear.cpp GYearMonth.cpp Time.cpp
  Log:
  Correct problem determining timezone offset in Date and Time Deserializers on Linux.
  
  PR: AXISCPP-321
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.9       +20 -16    ws-axis/c/src/soap/xsd/Date.cpp
  
  Index: Date.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Date.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Date.cpp	4 Feb 2005 12:41:59 -0000	1.8
  +++ Date.cpp	10 Feb 2005 14:11:42 -0000	1.9
  @@ -165,22 +165,26 @@
   	    AxisChar *cTemp;
   	    AxisChar *cTemp2;
   
  -	    time_t now;
  -	    time (&now);
  -	    pTm = gmtime (&now);
  -
  -	    struct tm result1;
  -	    memcpy (&result1, pTm, sizeof (tm));
  -
  -	    pTm = localtime (&now);
  -		struct tm result2;
  -	    memcpy (&result2, pTm, sizeof (tm));
  -
  -	    time_t d = mktime (&result1) - mktime (&result2);
  -	    if (d == -1)
  -    	{
  -	        throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -    	}
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.11      +22 -16    ws-axis/c/src/soap/xsd/DateTime.cpp
  
  Index: DateTime.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/DateTime.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DateTime.cpp	4 Feb 2005 12:41:59 -0000	1.10
  +++ DateTime.cpp	10 Feb 2005 14:11:42 -0000	1.11
  @@ -175,22 +175,28 @@
   	    AxisChar *cTemp2;
   	    AxisChar *cTemp3;
   
  -	    time_t now;
  -	    time (&now);
  -	    pTm = gmtime (&now);
  -
  -	    struct tm result1;
  -	    memcpy (&result1, pTm, sizeof (tm));
  -	    pTm = localtime (&now);
  -
  -	    struct tm result2;
  -	    memcpy (&result2, pTm, sizeof (tm));
  -
  -	    time_t d = mktime (&result1) - mktime (&result2);
  -	    if (d == -1)
  -	    {
  -	        throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -	    }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
  +
  +
   	
           /* dismantle valueAsChar to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.3       +20 -16    ws-axis/c/src/soap/xsd/GDay.cpp
  
  Index: GDay.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/GDay.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GDay.cpp	4 Feb 2005 12:41:59 -0000	1.2
  +++ GDay.cpp	10 Feb 2005 14:11:42 -0000	1.3
  @@ -164,22 +164,26 @@
         AxisChar *cTemp;
         AxisChar *cTemp2;
   
  -       time_t now;
  -       time (&now);
  -      pTm = gmtime (&now);
  -
  -        struct tm result1;
  -        memcpy (&result1, pTm, sizeof (tm));
  -
  -        pTm = localtime (&now);
  -       struct tm result2;
  -        memcpy (&result2, pTm, sizeof (tm));
  -
  -        time_t d = mktime (&result1) - mktime (&result2);
  -     if (d == -1)
  -      {
  -         throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -      }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.3       +20 -16    ws-axis/c/src/soap/xsd/GMonth.cpp
  
  Index: GMonth.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/GMonth.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GMonth.cpp	4 Feb 2005 12:41:59 -0000	1.2
  +++ GMonth.cpp	10 Feb 2005 14:11:42 -0000	1.3
  @@ -166,22 +166,26 @@
         AxisChar *cTemp;
         AxisChar *cTemp2;
   
  -       time_t now;
  -       time (&now);
  -      pTm = gmtime (&now);
  -
  -        struct tm result1;
  -        memcpy (&result1, pTm, sizeof (tm));
  -
  -        pTm = localtime (&now);
  -       struct tm result2;
  -        memcpy (&result2, pTm, sizeof (tm));
  -
  -        time_t d = mktime (&result1) - mktime (&result2);
  -     if (d == -1)
  -      {
  -         throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -      }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.3       +20 -16    ws-axis/c/src/soap/xsd/GMonthDay.cpp
  
  Index: GMonthDay.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/GMonthDay.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GMonthDay.cpp	4 Feb 2005 12:41:59 -0000	1.2
  +++ GMonthDay.cpp	10 Feb 2005 14:11:42 -0000	1.3
  @@ -165,22 +165,26 @@
         AxisChar *cTemp;
         AxisChar *cTemp2;
   
  -       time_t now;
  -       time (&now);
  -      pTm = gmtime (&now);
  -
  -        struct tm result1;
  -        memcpy (&result1, pTm, sizeof (tm));
  -
  -        pTm = localtime (&now);
  -       struct tm result2;
  -        memcpy (&result2, pTm, sizeof (tm));
  -
  -        time_t d = mktime (&result1) - mktime (&result2);
  -     if (d == -1)
  -      {
  -         throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -      }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.3       +20 -16    ws-axis/c/src/soap/xsd/GYear.cpp
  
  Index: GYear.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/GYear.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GYear.cpp	4 Feb 2005 12:41:59 -0000	1.2
  +++ GYear.cpp	10 Feb 2005 14:11:42 -0000	1.3
  @@ -165,22 +165,26 @@
         AxisChar *cTemp;
         AxisChar *cTemp2;
   
  -       time_t now;
  -       time (&now);
  -      pTm = gmtime (&now);
  -
  -        struct tm result1;
  -        memcpy (&result1, pTm, sizeof (tm));
  -
  -        pTm = localtime (&now);
  -       struct tm result2;
  -        memcpy (&result2, pTm, sizeof (tm));
  -
  -        time_t d = mktime (&result1) - mktime (&result2);
  -     if (d == -1)
  -      {
  -         throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -      }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.3       +20 -16    ws-axis/c/src/soap/xsd/GYearMonth.cpp
  
  Index: GYearMonth.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/GYearMonth.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GYearMonth.cpp	4 Feb 2005 12:41:59 -0000	1.2
  +++ GYearMonth.cpp	10 Feb 2005 14:11:42 -0000	1.3
  @@ -165,22 +165,26 @@
         AxisChar *cTemp;
         AxisChar *cTemp2;
   
  -       time_t now;
  -       time (&now);
  -      pTm = gmtime (&now);
  -
  -        struct tm result1;
  -        memcpy (&result1, pTm, sizeof (tm));
  -
  -        pTm = localtime (&now);
  -       struct tm result2;
  -        memcpy (&result2, pTm, sizeof (tm));
  -
  -        time_t d = mktime (&result1) - mktime (&result2);
  -     if (d == -1)
  -      {
  -         throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -      }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
   
           /* dismantle m_sValue to get tm value;
            * XSD_DATETIME format is
  
  
  
  1.9       +20 -16    ws-axis/c/src/soap/xsd/Time.cpp
  
  Index: Time.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Time.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Time.cpp	4 Feb 2005 12:41:59 -0000	1.8
  +++ Time.cpp	10 Feb 2005 14:11:42 -0000	1.9
  @@ -166,22 +166,26 @@
   	    AxisChar *cTemp2;
   	    AxisChar *cTemp3;
   
  -	    time_t now;
  -	    time (&now);
  -	    pTm = gmtime (&now);
  -
  -	    struct tm result1;
  -	    memcpy (&result1, pTm, sizeof (tm));
  -	    pTm = localtime (&now);
  -
  -	    struct tm result2;
  -	    memcpy (&result2, pTm, sizeof (tm));
  -
  -	    time_t d = mktime (&result1) - mktime (&result2);
  -	    if (d == -1)
  -	    {
  -	        throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
  -	    }
  +        // Calculate local timezone offset
  +        time_t now = 0;
  +        struct tm *temp = gmtime(&now);
  +        struct tm utcTime;
  +        memcpy(&utcTime, temp, sizeof(struct tm));
  +        temp = localtime(&now);
  +        struct tm localTime;
  +        memcpy(&localTime, temp, sizeof(struct tm));
  +
  +        long utcTimeInSeconds = (utcTime.tm_year * 60 * 60 * 24 * 365)
  +            + (utcTime.tm_yday * 60 * 60 * 24)
  +            + (utcTime.tm_hour * 60 * 60)
  +            + (utcTime.tm_min * 60);
  +
  +        long localTimeInSeconds = (localTime.tm_year * 60 * 60 * 24 * 365)
  +            + (localTime.tm_yday * 60 * 60 * 24)
  +            + (localTime.tm_hour * 60 * 60)
  +            + (localTime.tm_min * 60);
  +
  +        time_t d = utcTimeInSeconds - localTimeInSeconds;
       	
           /* dismantle valueAsChar to get tm value;
            * XSD_TIME format is