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/04 13:42:00 UTC
cvs commit: ws-axis/c/tests/auto_build/testcases/client/cpp AxisBenchClient.cpp
dicka 2005/02/04 04:42:00
Modified: c/src/soap/xsd Date.cpp DateTime.cpp GDay.cpp GMonth.cpp
GMonthDay.cpp GYear.cpp GYearMonth.cpp Time.cpp
c/tests/auto_build/testcases/client/cpp AxisBenchClient.cpp
Log:
Correct Date and Time object to determine timezone offset when serializing, and append to the outgoing Date/Time value.
PR: AXISCPP-321
Submitted by: Adrian Dick
Revision Changes Path
1.8 +77 -8 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Date.cpp 25 Jan 2005 11:26:38 -0000 1.7
+++ Date.cpp 4 Feb 2005 12:41:59 -0000 1.8
@@ -93,12 +93,67 @@
}
}
delete maxExclusive;
-
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "%Y-%m-%dZ", value);
+
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "%Y-%m-%d", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
+ IAnySimpleType::serialize(serializedValue.c_str());
return m_Buf;
}
@@ -135,7 +190,13 @@
if (sscanf (valueAsChar, "%d-%d-%d", &value.tm_year,
&value.tm_mon, &value.tm_mday) != 3)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ AxisString exceptionMessage =
+ "Unable to decompose from string form of DateTime value. Value =";
+ exceptionMessage += valueAsChar;
+ exceptionMessage += ".";
+
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
+ const_cast<AxisChar*>(exceptionMessage.c_str()));
}
value.tm_year -= 1900;
@@ -159,6 +220,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -198,7 +267,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -209,7 +278,7 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
if(m_Date)
1.10 +90 -23 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DateTime.cpp 25 Jan 2005 11:26:38 -0000 1.9
+++ DateTime.cpp 4 Feb 2005 12:41:59 -0000 1.10
@@ -102,12 +102,67 @@
}
}
delete maxExclusive;
-
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "%Y-%m-%dT%H:%M:%SZ", value);
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "%Y-%m-%dT%H:%M:%S", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
+
+ IAnySimpleType::serialize(serializedValue.c_str());
return m_Buf;
}
@@ -120,27 +175,24 @@
AxisChar *cTemp2;
AxisChar *cTemp3;
- time_t now;
-
- time(&now);
-
+ time_t now;
+ time (&now);
pTm = gmtime (&now);
struct tm result1;
memcpy (&result1, pTm, sizeof (tm));
pTm = localtime (&now);
- struct tm result2;
+ 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);
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- /* dismantle m_sValue to get tm value;
+ /* dismantle valueAsChar to get tm value;
* XSD_DATETIME format is
* CCYY(-)MM(-)DDThh:mm:ss.ss...Z OR
* CCYY(-)MM(-)DDThh:mm:ss.ss...+/-<UTC TIME DIFFERENCE>
@@ -149,8 +201,14 @@
&value.tm_mon, &value.tm_mday, &value.tm_hour, &value.tm_min,
&value.tm_sec) != 6)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
+ AxisString exceptionMessage =
+ "Unable to decompose from string form of DateTime value. Value =";
+ exceptionMessage += valueAsChar;
+ exceptionMessage += ".";
+
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
+ const_cast<AxisChar*>(exceptionMessage.c_str()));
+ }
value.tm_year -= 1900;
value.tm_mon--;
@@ -168,12 +226,21 @@
/*if the timezone is represented adding 'Z' at the end */
if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
{
- time_t temp = mktime (&value);
+ time_t temp = mktime (&value); // convert tm object to seconds
if (temp == -1)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ pTm = localtime (&temp); // construct tm object from seconds
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = localtime (&temp);
+
+ t = labs (t - d);
+ pTm = localtime (&t);
}
/*if the timezone is represented using +/-hh:mm format */
else if (len > (sizeof (char) * 6))
@@ -187,7 +254,7 @@
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int hours = 0;
@@ -195,7 +262,7 @@
if (sscanf (cUtc + 1, "%d:%d", &hours, &minutes) != 2)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int secs = hours * 60 * 60 + minutes * 60;
@@ -213,11 +280,11 @@
time_t t = mktime (&value);
if (t == -1)
{
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -228,7 +295,7 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
if(m_DateTime)
1.2 +71 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GDay.cpp 25 Jan 2005 18:08:30 -0000 1.1
+++ GDay.cpp 4 Feb 2005 12:41:59 -0000 1.2
@@ -94,11 +94,65 @@
}
delete maxExclusive;
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "---%d", value);
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "---%d", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
+ IAnySimpleType::serialize(serializedValue.c_str());
return m_Buf;
}
@@ -137,7 +191,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- value.tm_year = 1900;
+ value.tm_year = 70;
value.tm_mon--;
value.tm_mday = 0;
value.tm_hour = 0;
@@ -159,6 +213,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -198,7 +260,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -209,9 +271,10 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
-
+
+ pTm -= 70; // Take off the 70 offset we added initially
if(m_GDay)
{
delete m_GDay;
1.2 +72 -7 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GMonth.cpp 25 Jan 2005 18:08:30 -0000 1.1
+++ GMonth.cpp 4 Feb 2005 12:41:59 -0000 1.2
@@ -94,12 +94,68 @@
}
delete maxExclusive;
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "--%m--", value);
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "--%m--", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
+ IAnySimpleType::serialize(serializedValue.c_str());
return m_Buf;
+
}
struct tm* GMonth::deserializeGMonth(const AxisChar* valueAsChar) throw (AxisSoapException)
@@ -138,7 +194,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- value.tm_year = 1900;
+ value.tm_year = 70;
value.tm_mon--;
value.tm_mday = 0;
value.tm_hour = 0;
@@ -160,6 +216,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -199,7 +263,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -210,9 +274,10 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
+ pTm -= 70; // Take off the 70 offset we added initially
if(m_GMonth)
{
delete m_GMonth;
1.2 +74 -10 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GMonthDay.cpp 25 Jan 2005 18:08:30 -0000 1.1
+++ GMonthDay.cpp 4 Feb 2005 12:41:59 -0000 1.2
@@ -93,13 +93,68 @@
}
}
delete maxExclusive;
-
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "--%m-%d", value);
+
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "--%m-%d", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
- return m_Buf;
+ IAnySimpleType::serialize(serializedValue.c_str());
+ return m_Buf;
}
struct tm* GMonthDay::deserializeGMonthDay(const AxisChar* valueAsChar) throw (AxisSoapException)
@@ -138,7 +193,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- value.tm_year = 1900;
+ value.tm_year = 70;
value.tm_mon--;
value.tm_hour = 0;
value.tm_min = 0;
@@ -159,6 +214,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -198,7 +261,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -209,9 +272,10 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
-
+
+ pTm -= 70; // Take off the 70 offset we added initially
if(m_GMonthDay)
{
delete m_GMonthDay;
1.2 +70 -7 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GYear.cpp 25 Jan 2005 18:08:30 -0000 1.1
+++ GYear.cpp 4 Feb 2005 12:41:59 -0000 1.2
@@ -94,12 +94,67 @@
}
delete maxExclusive;
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "%Y", value);
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "%Y", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
- return m_Buf;
+ IAnySimpleType::serialize(serializedValue.c_str());
+ return m_Buf;
}
struct tm* GYear::deserializeGYear(const AxisChar* valueAsChar) throw (AxisSoapException)
@@ -159,6 +214,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -198,7 +261,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -209,7 +272,7 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
if(m_GYear)
1.2 +70 -7 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GYearMonth.cpp 25 Jan 2005 18:08:30 -0000 1.1
+++ GYearMonth.cpp 4 Feb 2005 12:41:59 -0000 1.2
@@ -93,12 +93,67 @@
}
}
delete maxExclusive;
-
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "%Y-%m", value);
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "%Y-%m", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
+
+ IAnySimpleType::serialize(serializedValue.c_str());
return m_Buf;
}
@@ -160,6 +215,14 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
}
else if (cTemp2 != NULL)
{
@@ -199,7 +262,7 @@
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
- pTm = gmtime (&t);
+ pTm = localtime (&t);
}
/*if the zone is not represented in the date */
else
@@ -210,7 +273,7 @@
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- pTm = gmtime (&timeInSecs);
+ pTm = localtime (&timeInSecs);
}
if(m_GYearMonth)
1.8 +157 -95 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Time.cpp 25 Jan 2005 11:26:38 -0000 1.7
+++ Time.cpp 4 Feb 2005 12:41:59 -0000 1.8
@@ -94,19 +94,73 @@
}
delete maxExclusive;
- AxisChar* serializedValue = new AxisChar[80];
- strftime (serializedValue, 80, "%H:%M:%SZ", value);
-
- IAnySimpleType::serialize(serializedValue);
- delete [] serializedValue;
- return m_Buf;
+ AxisString serializedValue = "";
+ AxisChar* valueAsString = new AxisChar[80];
+ strftime (valueAsString, 80, "%H:%M:%S", value);
+ serializedValue += valueAsString;
+ delete [] valueAsString;
+
+ // 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 utcTimeInMinutes = (utcTime.tm_year * 60 * 24 * 365)
+ + (utcTime.tm_yday * 60 * 24)
+ + (utcTime.tm_hour * 60)
+ + utcTime.tm_min;
+
+ long localTimeInMinutes = (localTime.tm_year * 60 * 24 * 365)
+ + (localTime.tm_yday * 60 * 24)
+ + (localTime.tm_hour * 60)
+ + localTime.tm_min;
+
+ int timeOffsetInMinutes = localTimeInMinutes - utcTimeInMinutes;
+
+ if (timeOffsetInMinutes == 0)
+ {
+ serializedValue += "Z";
+ }
+ else
+ {
+ struct tm timeOffset;
+ timeOffset.tm_year = 0;
+ timeOffset.tm_yday = 0;
+ timeOffset.tm_sec = 0;
+ timeOffset.tm_min = timeOffsetInMinutes % 60;
+ timeOffsetInMinutes -= timeOffset.tm_min;
+ timeOffset.tm_hour = (timeOffsetInMinutes % (60 * 24)) / 60;
+
+ if ( (timeOffset.tm_hour < 0) || (timeOffset.tm_min < 0) )
+ {
+ serializedValue += "-";
+ timeOffset.tm_hour *= -1;
+ timeOffset.tm_min *= -1;
+ }
+ else
+ {
+ serializedValue += "+";
+ }
+
+ AxisChar * offSetString = new AxisChar[6];
+ sprintf(offSetString, "%02i:%02i", timeOffset.tm_hour, timeOffset.tm_min);
+ serializedValue += offSetString;
+ delete [] offSetString;
+ }
+
+
+ IAnySimpleType::serialize(serializedValue.c_str());
+ return m_Buf;
}
struct tm* Time::deserializeTime(const AxisChar* valueAsChar) throw (AxisSoapException)
{
struct tm value;
- struct tm *pTm;
-
+ struct tm* pTm;
AxisChar *cUtc;
AxisChar *cTemp;
AxisChar *cTemp2;
@@ -115,112 +169,120 @@
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);
}
- /* dismantle m_sValue to get tm value;
- * XSD_TIME format is
- * hh:mm:ss.ss...Z OR
- * hh:mm:ss.ss...+/-<UTC TIME DIFFERENCE>
- */
- if (sscanf (valueAsChar, "%d:%d:%d", &value.tm_hour,
- &value.tm_min, &value.tm_sec) != 3)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
+ /* dismantle valueAsChar to get tm value;
+ * XSD_TIME format is
+ * hh:mm:ss.ss...Z OR
+ * hh:mm:ss.ss...+/-<UTC TIME DIFFERENCE>
+ */
+ if (sscanf (valueAsChar, "%d:%d:%d", &value.tm_hour,
+ &value.tm_min, &value.tm_sec) != 3)
+ {
+ AxisString exceptionMessage =
+ "Unable to decompose from string form of DateTime value. Value =";
+ exceptionMessage += valueAsChar;
+ exceptionMessage += ".";
+
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
+ const_cast<AxisChar*>(exceptionMessage.c_str()));
+ }
- value.tm_year = 70;
- value.tm_mon = 0;
- value.tm_mday = 1; /* Day of month (1 - 31) */
- value.tm_isdst = -1;
+ value.tm_year = 70;
+ value.tm_mon = 0;
+ value.tm_mday = 1; /* Day of month (1 - 31) */
+ value.tm_isdst = -1;
#if !defined(WIN32) && !defined(AIX) && !defined( __OS400__ ) && !defined(__sun)
- value.tm_zone = NULL;
- value.tm_gmtoff = -1;
+ value.tm_zone = NULL;
+ value.tm_gmtoff = -1;
#endif
+ cTemp2 = (char*) valueAsChar;
+ cTemp3 = strrchr (cTemp2, ':');
+ cTemp3[0] = '\0';
+ unsigned int len = strlen (cTemp2);
+ cTemp3[0] = ':';
- cTemp2 = (char*) valueAsChar;
- 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 temp = mktime (&value);
- if (temp == -1)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
- pTm = localtime (&temp);
- }
- /* if the timezone is represented using +/-hh:mm format */
-
- else if (len > (sizeof (char) * 6))
- {
- cUtc = strpbrk (cTemp2, "+");
- if (cUtc == NULL)
- {
- cUtc = strpbrk (cTemp2, "-");
- }
- time_t timeInSecs = mktime (&value);
- if (timeInSecs == -1)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
-
- int hours = 0;
- int mins = 0;
- if (sscanf (cUtc + 1, "%d:%d", &hours, &mins) != 2)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
-
- int secs = hours * 60 * 60 + mins * 60;
- 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)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
-
- //t = fabs (t - d);
- t = labs (t - d); // Samisa - use correct typed methods - we need long int; not double
- pTm = gmtime (&t);
+ /* if the timezone is represented adding 'Z' at the end */
+ if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
+ {
+ time_t temp = mktime (&value); // convert tm object to seconds
+ if (temp == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
- /* if the zone is not represented in the date */
- else
+ pTm = localtime (&temp); // construct tm object from seconds
+ memcpy (&value, pTm, sizeof (tm));
+ time_t t = mktime (&value);
+ if (t == -1)
{
- /* else it is assumed that the sent time is localtime */
- // memcpy(&m_TMUTC, &m_TM, sizeof(tm));
- time_t timeInSecs = mktime (&value);
- if (timeInSecs == -1)
- {
- throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
- }
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
+ }
+ /* if the timezone is represented using +/-hh:mm format */
+ else if (len > (sizeof (char) * 6))
+ {
+ cUtc = strpbrk (cTemp2, "+");
+ if (cUtc == NULL)
+ {
+ cUtc = strpbrk (cTemp2, "-");
+ }
+ time_t timeInSecs = mktime (&value);
+ if (timeInSecs == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+
+ int hours = 0;
+ int minutes = 0;
+ if (sscanf (cUtc + 1, "%d:%d", &hours, &minutes) != 2)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
- pTm = gmtime (&timeInSecs);
+ int secs = hours * 60 * 60 + minutes * 60;
+ 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)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ t = labs (t - d);
+ pTm = localtime (&t);
+ }
+ /* if the zone is not represented in the date */
+ else
+ {
+ /* else it is assumed that the sent time is localtime */
+ time_t timeInSecs = mktime (&value);
+ if (timeInSecs == -1)
+ {
+ throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
+ }
+ pTm = localtime (&timeInSecs);
+ }
if(m_Time)
{
1.18 +7 -4 ws-axis/c/tests/auto_build/testcases/client/cpp/AxisBenchClient.cpp
Index: AxisBenchClient.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/client/cpp/AxisBenchClient.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- AxisBenchClient.cpp 31 Jan 2005 16:38:18 -0000 1.17
+++ AxisBenchClient.cpp 4 Feb 2005 12:42:00 -0000 1.18
@@ -76,7 +76,10 @@
time_t tim;
tim = 1100246323;
- tm* lt = gmtime(&tim);
+ struct tm *temp = gmtime(&tim);
+ struct tm lt;
+ memcpy(<, temp, sizeof(struct tm));
+
buffer = (xsd__unsignedByte*)calloc (1, input->count + 2);
strcpy ( (char *)buffer, "A");
@@ -87,9 +90,9 @@
type->IntegerType = 10*(i+1);
type->DoubleType = 11.111 * (i+1);
type->BooleanType = true_;
- type->DateTimeType = *lt ;
- type->TimeType = *lt ;
- type->DateType = *lt ;
+ type->DateTimeType = lt ;
+ type->TimeType = lt ;
+ type->DateType = lt ;
type->IntType = (i+1);
type->ByteType = '1';
type->DecimalType = 10*(i+1);