summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorGravatar samisa2011-08-30 13:41:46 +0000
committerGravatar samisa2011-08-30 13:41:46 +0000
commit83cf57c2f3acc697686190fb8a0dd67297e642f9 (patch)
treef29b6d138a4b132131a2f40bf3147ae3d6fba3bb /util
parentcffb2c41bbc91d1a70440ad9fab5ee9593d84f67 (diff)
downloadaxis2c-83cf57c2f3acc697686190fb8a0dd67297e642f9.tar.gz
axis2c-83cf57c2f3acc697686190fb8a0dd67297e642f9.tar.bz2
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
Diffstat (limited to 'util')
-rw-r--r--util/src/date_time.c45
1 files 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 <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_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;
}