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 se...@apache.org on 2008/03/10 22:39:22 UTC

svn commit: r635706 - in /webservices/axis2/trunk/c/util: include/axutil_date_time.h src/date_time.c

Author: senaka
Date: Mon Mar 10 14:39:20 2008
New Revision: 635706

URL: http://svn.apache.org/viewvc?rev=635706&view=rev
Log:
Fixing JIRA Issue AXIS2C-1049

Modified:
    webservices/axis2/trunk/c/util/include/axutil_date_time.h
    webservices/axis2/trunk/c/util/src/date_time.c

Modified: webservices/axis2/trunk/c/util/include/axutil_date_time.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axutil_date_time.h?rev=635706&r1=635705&r2=635706&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axutil_date_time.h (original)
+++ webservices/axis2/trunk/c/util/include/axutil_date_time.h Mon Mar 10 14:39:20 2008
@@ -317,6 +317,16 @@
         const axutil_env_t * env,
         const axis2_char_t * time_str);
 
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axutil_date_time_serialize_date_time_with_time_zone(
+        axutil_date_time_t * date_time,
+        const axutil_env_t * env);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axutil_date_time_serialize_time_with_time_zone(
+        axutil_date_time_t * date_time,
+        const axutil_env_t * env);
+
 #ifdef __cplusplus
 }
 #endif

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=635706&r1=635705&r2=635706&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/date_time.c (original)
+++ webservices/axis2/trunk/c/util/src/date_time.c Mon Mar 10 14:39:20 2008
@@ -473,7 +473,10 @@
     const axutil_env_t * env,
     axutil_date_time_t * ref)
 {
-
+    int dt_min;
+    int ref_min;
+    int dt_hour;
+    int ref_hour;
     AXIS2_ENV_CHECK(env, AXIS2_DATE_TIME_COMP_RES_FAILURE);
 
     if (date_time->year < ref->year)
@@ -503,20 +506,40 @@
         return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
     }
 
-    if (date_time->hour < ref->hour)
+    dt_min = date_time->tz_min;
+    dt_hour = date_time->tz_hour;
+    ref_min = ref->tz_min;
+    ref_hour = ref->tz_hour;
+    if (date_time->tz_pos)
+    {
+        dt_min *= -1;
+        dt_hour *= -1;
+    }
+    if (ref->tz_pos)
+    {
+        ref_min *= -1;
+        ref_hour *= -1;
+    }
+
+    dt_min += date_time->min;
+    dt_hour += date_time->hour;
+    ref_min += ref->min;
+    ref_hour += ref->hour;
+
+    if (dt_hour < ref_hour)
     {
         return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
     }
-    else if (date_time->hour > ref->hour)
+    else if (dt_hour > ref_hour)
     {
         return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
     }
 
-    if (date_time->min < ref->min)
+    if (dt_min < ref_min)
     {
         return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
     }
-    else if (date_time->min > ref->min)
+    else if (dt_min > ref_min)
     {
         return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
     }
@@ -648,12 +671,31 @@
         (axis2_char_t *) AXIS2_MALLOC(env->allocator,
                                       sizeof(axis2_char_t) * 32);
 
-    sprintf(time_str, "%d:%d:%d.%dZ", date_time->hour, date_time->min,
+    sprintf(time_str, "%02d:%02d:%02d.%03dZ", date_time->hour, date_time->min,
             date_time->sec, date_time->msec);
     return time_str;
 }
 
 AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+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_ENV_CHECK(env, NULL);
+
+    time_str =
+        (axis2_char_t *) AXIS2_MALLOC(env->allocator,
+                                      sizeof(axis2_char_t) * 37);
+
+    sprintf(time_str, "%02d:%02d:%02d.%03d%c%02d:%02d", date_time->hour, date_time->min,
+            date_time->sec, date_time->msec, date_time->tz_pos ? '+': '-',
+            date_time->tz_hour, date_time->tz_min);
+    return time_str;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axutil_date_time_serialize_date(
     axutil_date_time_t * date_time,
     const axutil_env_t * env)
@@ -666,13 +708,13 @@
         (axis2_char_t *) AXIS2_MALLOC(env->allocator,
                                       sizeof(axis2_char_t) * 32);
 
-    sprintf(date_str, "%d-%d-%d", date_time->year + 1900, date_time->mon + 1,
+    sprintf(date_str, "%d-%02d-%02d", date_time->year + 1900, date_time->mon + 1,
             date_time->day);
     return date_str;
 }
 
 AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axutil_date_time_serialize_date_time(
+axutil_date_time_serialize_date_time_with_time_zone(
     axutil_date_time_t * date_time,
     const axutil_env_t * env)
 {
@@ -687,6 +729,23 @@
     return date_time_str;
 }
 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+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_ENV_CHECK(env, NULL);
+
+    date_time_str = AXIS2_MALLOC(env->allocator, sizeof(char) * 37);
+    sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%02d.%03d%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->msec, 
+            date_time->tz_pos ? '+': '-', date_time->tz_hour, date_time->tz_min);
+    return date_time_str;
+}
+
 AXIS2_EXTERN int AXIS2_CALL
 axutil_date_time_get_year(
     axutil_date_time_t * date_time,
@@ -790,7 +849,8 @@
     day = date_time->day;
     hour = date_time->hour;
     min = date_time->min;
-    sec = date_time->msec;
+    sec = date_time->sec;
+    msec = date_time->msec;
     tz_pos = date_time->tz_pos;
     tz_hour = date_time->tz_hour;
     tz_min = date_time->tz_min;
@@ -798,12 +858,9 @@
     if (!tz_pos)
     {
         tz_hour *= -1;
-    }
-    hour += tz_hour;
-    if (!tz_pos)
-    {
         tz_min *= -1;
     }
+    hour += tz_hour;
     min += tz_min;
 
     if (min > 59)



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