]> granicus.if.org Git - apache/blob - include/util_time.h
update transformation
[apache] / include / util_time.h
1 /* Copyright 2001-2004 The Apache Software Foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef APACHE_UTIL_TIME_H
17 #define APACHE_UTIL_TIME_H
18
19 #include "apr.h"
20 #include "apr_time.h"
21 #include "httpd.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @package Apache date-time handling functions
29  */
30
31 /* Maximum delta from the current time, in seconds, for a past time
32  * to qualify as "recent" for use in the ap_explode_recent_*() functions:
33  * (Must be a power of two minus one!)
34  */
35 #define AP_TIME_RECENT_THRESHOLD 15
36
37 /**
38  * convert a recent time to its human readable components in local timezone
39  * @param tm the exploded time
40  * @param t the time to explode: MUST be within the last
41  *          AP_TIME_RECENT_THRESHOLD seconds
42  * @note This is a faster alternative to apr_time_exp_lt that uses
43  *       a cache of pre-exploded time structures.  It is useful for things
44  *       that need to explode the current time multiple times per second,
45  *       like loggers.
46  * @return APR_SUCCESS iff successful
47  */
48 AP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm,
49                                                      apr_time_t t);
50
51 /**
52  * convert a recent time to its human readable components in GMT timezone
53  * @param tm the exploded time
54  * @param t the time to explode: MUST be within the last
55  *          AP_TIME_RECENT_THRESHOLD seconds
56  * @note This is a faster alternative to apr_time_exp_gmt that uses
57  *       a cache of pre-exploded time structures.  It is useful for things
58  *       that need to explode the current time multiple times per second,
59  *       like loggers.
60  * @return APR_SUCCESS iff successful
61  */
62 AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm,
63                                                apr_time_t t);
64
65
66 /**
67  * format a recent timestamp in the ctime() format.
68  * @param date_str String to write to.
69  * @param t the time to convert 
70  */
71 AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t);
72
73 /**
74  * format a recent timestamp in the RFC822 format
75  * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
76  * @param t the time to convert 
77  */
78 AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t);
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #endif  /* !APACHE_UTIL_TIME_H */