You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2007/03/28 07:17:01 UTC

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

Author: kaushalye
Date: Tue Mar 27 22:17:00 2007
New Revision: 523179

URL: http://svn.apache.org/viewvc?view=rev&rev=523179
Log:
Adding comparison method to axis2_date_time.


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

Modified: webservices/axis2/trunk/c/util/include/axis2_date_time.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_date_time.h?view=diff&rev=523179&r1=523178&r2=523179
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_date_time.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_date_time.h Tue Mar 27 22:17:00 2007
@@ -39,6 +39,15 @@
 
     typedef struct axis2_date_time axis2_date_time_t;
 
+
+    typedef enum  {
+        AXIS2_DATE_TIME_COMP_RES_FAILURE = -1,
+        AXIS2_DATE_TIME_COMP_RES_UNKNOWN,
+        AXIS2_DATE_TIME_COMP_RES_EXPIRED,
+        AXIS2_DATE_TIME_COMP_RES_EQUAL,
+        AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED
+    }axis2_date_time_comp_result_t; 
+
     /**
      * Creates axis2_date_time struct with current date time
      * @param env double pointer to environment struct. MUST NOT be NULL
@@ -216,6 +225,19 @@
     AXIS2_EXTERN int AXIS2_CALL 
     axis2_date_time_get_msec(axis2_date_time_t *date_time,
         const axis2_env_t *env);
+    /**
+     * Compare the date and time of @date_time with the reference @ref.
+     * If the @date_time < @ref this returns NOT_EXPIRED.
+     * If the @date_time > @ref this returns EXPIRED.
+     * If the @date_time = @ref this returns EQUAL.
+     * @param date_time the date time to be compared
+     * @param env pointer to environment struct. MUST NOT be NULL
+     * @ref the reference date time
+     * @return NOT_EXPIRED/EXPIRED/EQUAL if valid otherwise return FAILURE
+     */
+    AXIS2_EXTERN axis2_date_time_comp_result_t AXIS2_CALL
+    axis2_date_time_compare(axis2_date_time_t *date_time,   
+        const axis2_env_t *env, axis2_date_time_t *ref);
 
 #ifdef __cplusplus
 }

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?view=diff&rev=523179&r1=523178&r2=523179
==============================================================================
--- webservices/axis2/trunk/c/util/src/date_time.c (original)
+++ webservices/axis2/trunk/c/util/src/date_time.c Tue Mar 27 22:17:00 2007
@@ -126,6 +126,59 @@
     return AXIS2_SUCCESS;
 }
 
+/*Check if the @data_time is not expired, compared to @ref*/
+AXIS2_EXTERN axis2_date_time_comp_result_t AXIS2_CALL
+axis2_date_time_compare(axis2_date_time_t *date_time,
+        const axis2_env_t *env, axis2_date_time_t *ref)
+{
+   
+   AXIS2_ENV_CHECK(env, AXIS2_DATE_TIME_COMP_RES_FAILURE);
+  
+   if(date_time->year < ref->year){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->year > ref->year){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->mon < ref->mon ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->mon > ref->mon){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->day < ref->day ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->day > ref->day){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->hour < ref->hour ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->hour > ref->hour){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->min < ref->min ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->min > ref->min){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->sec < ref->sec ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->sec > ref->sec){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+
+   if(date_time->msec < ref->msec ){
+        return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED; 
+   }else if(date_time->msec > ref->msec){
+        return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
+   }
+   
+   return AXIS2_DATE_TIME_COMP_RES_EQUAL;
+}
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_date_time_set_date_time(axis2_date_time_t* date_time,
         const axis2_env_t *env,
@@ -204,6 +257,7 @@
 {
     return (date_time->mon);
 }
+
 
 AXIS2_EXTERN int AXIS2_CALL
 axis2_date_time_get_date(axis2_date_time_t *date_time,



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