diff options
author | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 1999-12-21 21:16:19 +0000 |
---|---|---|
committer | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 1999-12-21 21:16:19 +0000 |
commit | eb33e963224602394247408aa49e8533b0f6498e (patch) | |
tree | 6d8393f576de78bf170123cadeefa3236784082a /time | |
parent | 24b18ea322060aa6ba532384bcaa0ce2a5ce3372 (diff) | |
download | libapr-eb33e963224602394247408aa49e8533b0f6498e.tar.gz |
A couple of new functions for APR's time library.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59549 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'time')
-rw-r--r-- | time/unix/access.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/time/unix/access.c b/time/unix/access.c index 1dcdfc2c5..46821e9e4 100644 --- a/time/unix/access.c +++ b/time/unix/access.c @@ -383,3 +383,40 @@ ap_status_t ap_set_timedata(struct atime_t *atime, void *data, char *key, } } +#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 + + |