util_time.h revision b5033962c73a470b6f36a3ac796c542a6ab4ddf6
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess/* ====================================================================
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd *
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess *
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * Redistribution and use in source and binary forms, with or without
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * modification, are permitted provided that the following conditions
5a58787efeb02a1c3f06569d019ad81fd2efa06end * are met:
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc *
5a58787efeb02a1c3f06569d019ad81fd2efa06end * 1. Redistributions of source code must retain the above copyright
5a58787efeb02a1c3f06569d019ad81fd2efa06end * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * distribution.
5a58787efeb02a1c3f06569d019ad81fd2efa06end *
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * 3. The end-user documentation included with the redistribution,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if any, must include the following acknowledgment:
5a58787efeb02a1c3f06569d019ad81fd2efa06end * "This product includes software developed by the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Apache Software Foundation (http://www.apache.org/)."
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Alternately, this acknowledgment may appear in the software itself,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if and wherever such third-party acknowledgments normally appear.
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd *
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * 4. The names "Apache" and "Apache Software Foundation" must
1a5a0356d04b1772b5a6b77c972774ab68832f81gryzor * not be used to endorse or promote products derived from this
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi * software without prior written permission. For written
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * permission, please contact apache@apache.org.
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd *
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * 5. Products derived from this software may not be called "Apache",
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * nor may "Apache" appear in their name, without prior written
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * permission of the Apache Software Foundation.
7f00ddc9c755823499db728b0609745950011029rbowen *
86b34f467542ab83f0f5ecd1bc086885d6baf4d8rbowen * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
03a229dcd0273c27b17f6c75bd0ad5425a8c7964rbowen * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
5a58787efeb02a1c3f06569d019ad81fd2efa06end * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5a58787efeb02a1c3f06569d019ad81fd2efa06end * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5a58787efeb02a1c3f06569d019ad81fd2efa06end * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6c46094bd2f1962cf16005bccf251ed796b3bd22rbowen * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
686152b8cc4fcd903d97871b6e67a3c718f237e5nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5ae30adbe59946de742ab0cd6be3b7457471a698takashi * SUCH DAMAGE.
686152b8cc4fcd903d97871b6e67a3c718f237e5nd * ====================================================================
03a229dcd0273c27b17f6c75bd0ad5425a8c7964rbowen *
03a229dcd0273c27b17f6c75bd0ad5425a8c7964rbowen * This software consists of voluntary contributions made by many
6573ba7a29e751dd173bb697d8432d540b364f63rbowen * individuals on behalf of the Apache Software Foundation. For more
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * information on the Apache Software Foundation, please see
5a58787efeb02a1c3f06569d019ad81fd2efa06end * <http://www.apache.org/>.
5a58787efeb02a1c3f06569d019ad81fd2efa06end *
5a58787efeb02a1c3f06569d019ad81fd2efa06end */
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess#ifndef APACHE_UTIL_TIME_H
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess#define APACHE_UTIL_TIME_H
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess#include "apr.h"
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess#include "apr_time.h"
4aa603e6448b99f9371397d439795c91a93637eand#include "httpd.h"
9a367ec3d570bcbaf8923dad66cb3b1532963964trawick
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coar#ifdef __cplusplus
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coarextern "C" {
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen#endif
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen/**
9a367ec3d570bcbaf8923dad66cb3b1532963964trawick * @package Apache date/time handling functions
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coar */
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coar
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess/* Maximum delta from the current time, in seconds, for a past time
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * to qualify as "recent" for use in the ap_explode_recent_*() functions:
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen */
9a367ec3d570bcbaf8923dad66cb3b1532963964trawick#define AP_TIME_RECENT_THRESHOLD 15
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coar
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coar/**
4aa603e6448b99f9371397d439795c91a93637eand * convert a recent time to its human readable components in local timezone
c3c006c28c5b03892ccaef6e4d2cbb15a13a2072rbowen * @param tm the exploded time
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen * @param t the time to explode: MUST be within the last
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen * AP_TIME_RECENT_THRESHOLD seconds
2c25a87ecb67ac197ee8283ee24fb5ad801fdf31rbowen * @note This is a faster alternative to apr_explode_localtime that uses
686152b8cc4fcd903d97871b6e67a3c718f237e5nd * a cache of pre-exploded time structures. It is useful for things
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * that need to explode the current time multiple times per second,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * like loggers.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * @return APR_SUCCESS iff successful
686152b8cc4fcd903d97871b6e67a3c718f237e5nd */
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowenAP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm,
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen apr_time_t t);
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess/**
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * convert a recent time to its human readable components in GMT timezone
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * @param tm the exploded time
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * @param t the time to explode: MUST be within the last
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * AP_TIME_RECENT_THRESHOLD seconds
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * @note This is a faster alternative to apr_explode_gmt that uses
686152b8cc4fcd903d97871b6e67a3c718f237e5nd * a cache of pre-exploded time structures. It is useful for things
686152b8cc4fcd903d97871b6e67a3c718f237e5nd * that need to explode the current time multiple times per second,
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * like loggers.
20e82b67dc8293dffb0c5c8001adaa7a23bcf694rbowen * @return APR_SUCCESS iff successful
20e82b67dc8293dffb0c5c8001adaa7a23bcf694rbowen */
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowenAP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm,
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen apr_time_t t);
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess
5a58787efeb02a1c3f06569d019ad81fd2efa06end/**
5a58787efeb02a1c3f06569d019ad81fd2efa06end * format a recent timestamp in the ctime() format.
5a58787efeb02a1c3f06569d019ad81fd2efa06end * @param date_str String to write to.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess * @param t the time to convert
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess */
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kessAP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t);
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess
686152b8cc4fcd903d97871b6e67a3c718f237e5nd#ifdef __cplusplus
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess}
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf#endif
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf#endif /* !APACHE_UTIL_TIME_H */
368dfa95fcdacd74ae9c927fc66cec543ccb4a00rbowen