From 83cf57c2f3acc697686190fb8a0dd67297e642f9 Mon Sep 17 00:00:00 2001 From: samisa Date: Tue, 30 Aug 2011 13:41:46 +0000 Subject: applied date time issue fixing patch provided in AXIS2C-1500 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@1163206 13f79535-47bb-0310-9956-ffa450edef68 --- util/src/date_time.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/util/src/date_time.c b/util/src/date_time.c index 55f26d5..f864e4a 100644 --- a/util/src/date_time.c +++ b/util/src/date_time.c @@ -22,6 +22,7 @@ #include #include #include +#include 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_time_zone( 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_time_zone( 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_with_time_zone( 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_with_time_zone( 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; } -- cgit v1.1-32-gdbae