axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r1163206 - /axis/axis2/c/core/trunk/util/src/date_time.c
Date Tue, 30 Aug 2011 13:41:47 GMT
Author: samisa
Date: Tue Aug 30 13:41:46 2011
New Revision: 1163206

URL: http://svn.apache.org/viewvc?rev=1163206&view=rev
Log:
applied date time issue fixing patch provided in AXIS2C-1500

Modified:
    axis/axis2/c/core/trunk/util/src/date_time.c

Modified: axis/axis2/c/core/trunk/util/src/date_time.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/src/date_time.c?rev=1163206&r1=1163205&r2=1163206&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/src/date_time.c (original)
+++ axis/axis2/c/core/trunk/util/src/date_time.c Tue Aug 30 13:41:46 2011
@@ -22,6 +22,7 @@
 #include <axutil_error.h>
 #include <axutil_utils.h>
 #include <axutil_date_time_util.h>
+#include <axutil_string.h>
 
 struct axutil_date_time
 {
@@ -619,12 +620,21 @@ axutil_date_time_serialize_time(
     axutil_date_time_t *date_time,
     const axutil_env_t *env)
 {
-    axis2_char_t *time_str = NULL;
+    axis2_char_t *time_str = NULL, *p = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
     time_str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 32);
     sprintf(time_str, "%02d:%02d:%06.3fZ", date_time->hour, date_time->min, date_time->sec);
+
+    /* 
+     * Ensure that milliseconds are separated with dot, 
+     * no matter which separator is specified in locale.
+     * Dot is required by http://www.w3.org/TR/xmlschema-2/#dateTime 
+     */
+    p = axutil_strchr(time_str, ',');
+    if (p) *p = '.';
+
     return time_str;
 }
 
@@ -633,7 +643,7 @@ axutil_date_time_serialize_time_with_tim
     axutil_date_time_t *date_time,
     const axutil_env_t *env)
 {
-    axis2_char_t *time_str = NULL;
+    axis2_char_t *time_str = NULL, *p = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
@@ -645,6 +655,15 @@ axutil_date_time_serialize_time_with_tim
     time_str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 37);
     sprintf(time_str, "%02d:%02d:%06.3f%c%02d:%02d", date_time->hour, date_time->min,
         date_time->sec, date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
+
+    /* 
+     * Ensure that milliseconds are separated with dot, 
+     * no matter which separator is specified in locale.
+     * Dot is required by http://www.w3.org/TR/xmlschema-2/#dateTime 
+     */
+    p = axutil_strchr(time_str, ',');
+    if (p) *p = '.';
+
     return time_str;
 }
 
@@ -668,13 +687,22 @@ axutil_date_time_serialize_date_time(
     axutil_date_time_t *date_time,
     const axutil_env_t *env)
 {
-    axis2_char_t *date_time_str = NULL;
+    axis2_char_t *date_time_str = NULL, *p = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
     date_time_str = AXIS2_MALLOC(env->allocator, sizeof(char) * 32);
     sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%06.3fZ", date_time->year + 1900, date_time->mon
         + 1, date_time->day, date_time->hour, date_time->min, date_time->sec);
+    
+    /* 
+     * Ensure that milliseconds are separated with dot, 
+     * no matter which separator is specified in locale.
+     * Dot is required by http://www.w3.org/TR/xmlschema-2/#dateTime 
+     */
+    p = axutil_strchr(date_time_str, ',');
+    if (p) *p = '.';
+
     return date_time_str;
 }
 
@@ -698,7 +726,7 @@ axutil_date_time_serialize_date_time_wit
     axutil_date_time_t *date_time,
     const axutil_env_t *env)
 {
-    axis2_char_t *date_time_str = NULL;
+    axis2_char_t *date_time_str = NULL, *p = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
@@ -711,6 +739,15 @@ axutil_date_time_serialize_date_time_wit
     sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%06.3f%c%02d:%02d", date_time->year
+ 1900,
         date_time->mon + 1, date_time->day, date_time->hour, date_time->min,
date_time->sec,
         date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
+
+    /* 
+     * Ensure that milliseconds are separated with dot, 
+     * no matter which separator is specified in locale.
+     * Dot is required by http://www.w3.org/TR/xmlschema-2/#dateTime 
+     */
+    p = axutil_strchr(date_time_str, ',');
+    if (p) *p = '.';
+
     return date_time_str;
 }
 



Mime
View raw message