axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sen...@apache.org
Subject svn commit: r635937 - /webservices/axis2/trunk/c/util/src/date_time.c
Date Tue, 11 Mar 2008 14:25:36 GMT
Author: senaka
Date: Tue Mar 11 07:25:32 2008
New Revision: 635937

URL: http://svn.apache.org/viewvc?rev=635937&view=rev
Log:
Fixing Issues reported in AXIS2C-1049

Modified:
    webservices/axis2/trunk/c/util/src/date_time.c

Modified: webservices/axis2/trunk/c/util/src/date_time.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/date_time.c?rev=635937&r1=635936&r2=635937&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/date_time.c (original)
+++ webservices/axis2/trunk/c/util/src/date_time.c Tue Mar 11 07:25:32 2008
@@ -110,8 +110,17 @@
     int msec;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    sscanf(time_str, "%d:%d:%d.%dZ", &hour, &min,
-           &sec, &msec);
+    if (strchr(time_str, '.'))
+    {
+        sscanf(time_str, "%d:%d:%d.%dZ", &hour, &min,
+               &sec, &msec);
+    }
+    else
+    {
+        sscanf(time_str, "%d:%d:%dZ", &hour, &min,
+               &sec);
+        msec = 0;
+    }
     if (hour < 0 || hour > 23)
     {
         return AXIS2_FAILURE;
@@ -145,10 +154,10 @@
     int min;
     int sec;
     int msec;
-	int tz_hour;
+    int tz_hour;
     int tz_min;
 
-    axis2_bool_t tz_pos = AXIS2_TRUE;;
+    axis2_bool_t tz_pos = AXIS2_TRUE;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
@@ -163,13 +172,31 @@
 
     if (tz_pos)
     {
-        sscanf(time_str, "%d:%d:%d.%d+%d:%d", &hour, &min,
-               &sec, &msec, &tz_hour, &tz_min);
+        if (strchr(time_str, '.'))
+        {
+            sscanf(time_str, "%d:%d:%d.%d+%d:%d", &hour, &min,
+                   &sec, &msec, &tz_hour, &tz_min);
+        }
+        else
+        {
+            sscanf(time_str, "%d:%d:%d+%d:%d", &hour, &min,
+                   &sec, &tz_hour, &tz_min);
+            msec = 0;
+        }
     }
     else
     {
-        sscanf(time_str, "%d:%d:%d.%d-%d:%d", &hour, &min,
-               &sec, &msec, &tz_hour, &tz_min);
+        if (strchr(time_str, '.'))
+        {
+            sscanf(time_str, "%d:%d:%d.%d-%d:%d", &hour, &min,
+                   &sec, &msec, &tz_hour, &tz_min);
+        }
+        else
+        {
+            sscanf(time_str, "%d:%d:%d-%d:%d", &hour, &min,
+                   &sec, &tz_hour, &tz_min);
+            msec = 0;
+        }
     }
     if (hour < 0 || hour > 23)
     {
@@ -229,7 +256,6 @@
     {
         is_year_neg++;
     }
-
     sscanf(date_str + is_year_neg, "%d-%d-%d", &year, &mon,
            &day);
     if (is_year_neg)
@@ -290,10 +316,18 @@
     {
         is_year_neg++;
     }
-
-    sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%dZ", &year,
-           &mon, &day, &hour, &min,
-           &sec, &msec);
+    if (strchr(date_time_str, '.'))
+    {
+        sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%dZ", &year,
+               &mon, &day, &hour, &min,
+               &sec, &msec);
+    }
+    else
+    {
+        sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%dZ", &year,
+               &mon, &day, &hour, &min, &sec);
+        msec = 0;
+    }
 
     if (is_year_neg)
     {
@@ -362,10 +396,10 @@
     int min;
     int sec;
     int msec;
-	int tz_hour;
+    int tz_hour;
     int tz_min;
     int is_year_neg = 0;
-    axis2_bool_t tz_pos = AXIS2_FALSE;;
+    axis2_bool_t tz_pos = AXIS2_FALSE;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
@@ -389,15 +423,37 @@
 
     if (tz_pos)
     {
-        sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%d+%d:%d", &year,
-               &mon, &day, &hour, &min,
-               &sec, &msec, &tz_hour, &tz_min);
+        if (strchr(date_time_str, '.'))
+        {
+            sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%d+%d:%d", &year,
+                   &mon, &day, &hour, &min,
+                   &sec, &msec, &tz_hour, &tz_min);
+        }
+        else
+        {
+            sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d+%d:%d", &year,
+                   &mon, &day, &hour, &min,
+                   &sec, &tz_hour, &tz_min);
+
+            msec = 0;
+        }
     }
     else
     {
-        sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%d-%d:%d", &year,
-               &mon, &day, &hour, &min,
-               &sec, &msec, &tz_hour, &tz_min);
+        if (strchr(date_time_str, '.'))
+        {
+            sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d.%d-%d:%d", &year,
+                   &mon, &day, &hour, &min,
+                   &sec, &msec, &tz_hour, &tz_min);
+        }
+        else
+        {
+            sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%d-%d:%d", &year,
+                   &mon, &day, &hour, &min,
+                   &sec, &tz_hour, &tz_min);
+
+            msec = 0;
+        }
     }
 
     if (is_year_neg)
@@ -842,7 +898,7 @@
     int min;
     int sec;
     int msec;
-	int tz_hour;
+    int tz_hour;
     int tz_min;
     axis2_bool_t tz_pos = AXIS2_FALSE;
     
@@ -1038,7 +1094,7 @@
     int min)
 {
     axutil_date_time_t * date_time = NULL;
-	axutil_date_time_t *ret = NULL;
+    axutil_date_time_t *ret = NULL;
     if (date_time_in->tz_hour && date_time_in->tz_min)
     {
         return NULL;
@@ -1054,8 +1110,7 @@
     date_time->tz_min = min;
     
     date_time->tz_pos = is_positive ? AXIS2_FALSE : AXIS2_TRUE;
-    ret = 
-        axutil_date_time_local_to_utc(date_time, env);
+    ret = axutil_date_time_local_to_utc(date_time, env);
     ret->tz_hour = hour;
     ret->tz_min = min;
     



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message