rbb         99/12/21 13:16:20

  Modified:    src/lib/apr acconfig.h aclocal.m4 configure.in
               src/lib/apr/include apr_time.h
               src/lib/apr/time/unix access.c
  Log:
  A couple of new functions for APR's time library.
  
  Revision  Changes    Path
  1.17      +2 -0      apache-2.0/src/lib/apr/acconfig.h
  
  Index: acconfig.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/acconfig.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- acconfig.h        1999/12/06 15:47:42     1.16
  +++ acconfig.h        1999/12/21 21:16:14     1.17
  @@ -44,6 +44,8 @@
   #undef NEED_RLIM_T
   #undef USEBCOPY
   
  +#undef HAVE_GMTOFF
  +
   #undef SIZEOF_SSIZE_T
   
   @BOTTOM@
  
  
  
  1.7       +0 -1      apache-2.0/src/lib/apr/aclocal.m4
  
  Index: aclocal.m4
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/aclocal.m4,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- aclocal.m4        1999/11/13 00:07:04     1.6
  +++ aclocal.m4        1999/12/21 21:16:17     1.7
  @@ -161,4 +161,3 @@
   undefine([AC_CV_NAME])dnl
   ])
   
  -
  
  
  
  1.37      +8 -0      apache-2.0/src/lib/apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/configure.in,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- configure.in      1999/12/19 18:09:59     1.36
  +++ configure.in      1999/12/21 21:16:17     1.37
  @@ -367,6 +367,14 @@
   AC_SUBST(sys_typesh)
   AC_SUBST(sys_uioh)
   
  +AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  +[AC_TRY_COMPILE([#include <sys/types.h>
  +#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  +  ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  +
  +if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
  +    AC_DEFINE(HAVE_GMTOFF)
  +fi
   
   MAKEFILE1="Makefile lib/Makefile "
   SUBDIRS="lib "
  
  
  
  1.6       +2 -0      apache-2.0/src/lib/apr/include/apr_time.h
  
  Index: apr_time.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_time.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apr_time.h        1999/12/21 16:21:41     1.5
  +++ apr_time.h        1999/12/21 21:16:19     1.6
  @@ -101,6 +101,8 @@
   ap_status_t ap_set_wday(ap_time_t *, ap_int32_t);
   ap_status_t ap_timecmp(ap_time_t *a, ap_time_t *b);
   
  +ap_status_t ap_get_gmtoff(int *tz, ap_time_t *tt, ap_context_t *cont);
  +
   ap_status_t ap_get_timedata(ap_time_t *, char *, void *);
   ap_status_t ap_set_timedata(ap_time_t *, void *, char *,
                               ap_status_t (*cleanup) (void *));
  
  
  
  1.9       +37 -0     apache-2.0/src/lib/apr/time/unix/access.c
  
  Index: access.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/time/unix/access.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- access.c  1999/12/20 16:10:15     1.8
  +++ access.c  1999/12/21 21:16:19     1.9
  @@ -383,3 +383,40 @@
       }
   }
   
  +#if defined(HAVE_GMTOFF)
  +ap_status_t ap_get_gmtoff(int *tz, ap_time_t *tt, ap_context_t *cont)
  +{
  +    if (tt->currtime == NULL) {
  +        tt->currtime = ap_pcalloc(cont, sizeof(struct timeval));
  +    }
  +    tt->currtime->tv_sec = time(NULL);
  +    tt->explodedtime = localtime(&tt->currtime->tv_sec);
  +    *tz = (int) (tt->explodedtime->tm_gmtoff / 60);
  +    return APR_SUCCESS;
  +}
  +#else
  +ap_status_t ap_get_gmtoff(int *tz, ap_time_t *tt, ap_context_t *cont)
  +{
  +    struct tm gmt;
  +    int days, hours, minutes;
  +
  +    if (tt->currtime == NULL) {
  +        tt->currtime = ap_pcalloc(cont, sizeof(struct timeval));
  +    }
  +    tt->currtime->tv_sec = time(NULL);
  +
  +    /* Assume we are never more than 24 hours away. */
  +    /* remember gmtime/localtime return ptr to static */
  +    /* buffer... so be careful */
  +    gmt = *gmtime(&tt->currtime->tv_sec); 
  +    tt->explodedtime = localtime(&tt->currtime->tv_sec);
  +    days = tt->explodedtime->tm_yday - gmt.tm_yday;
  +    hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24)
  +             + tt->explodedtime->tm_hour - gmt.tm_hour);
  +    minutes = hours * 60 + tt->explodedtime->tm_min - gmt.tm_min;
  +    *tz = minutes;
  +    return APR_SUCCESS;
  +}
  +#endif
  +
  +
  
  
  

Reply via email to