|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* @file util_time.h
|
|
Packit |
90a5c9 |
* @brief Apache date-time handling functions
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @defgroup APACHE_CORE_TIME Date-time handling functions
|
|
Packit |
90a5c9 |
* @ingroup APACHE_CORE
|
|
Packit |
90a5c9 |
* @{
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifndef APACHE_UTIL_TIME_H
|
|
Packit |
90a5c9 |
#define APACHE_UTIL_TIME_H
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr.h"
|
|
Packit |
90a5c9 |
#include "apr_time.h"
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef __cplusplus
|
|
Packit |
90a5c9 |
extern "C" {
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Maximum delta from the current time, in seconds, for a past time
|
|
Packit |
90a5c9 |
* to qualify as "recent" for use in the ap_explode_recent_*() functions:
|
|
Packit |
90a5c9 |
* (Must be a power of two minus one!)
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
#define AP_TIME_RECENT_THRESHOLD 15
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Options for ap_recent_ctime_ex */
|
|
Packit |
90a5c9 |
/* No extension */
|
|
Packit |
90a5c9 |
#define AP_CTIME_OPTION_NONE 0x0
|
|
Packit |
90a5c9 |
/* Add sub second timestamps with micro second resolution */
|
|
Packit |
90a5c9 |
#define AP_CTIME_OPTION_USEC 0x1
|
|
Packit |
90a5c9 |
/* Use more compact ISO 8601 format */
|
|
Packit |
90a5c9 |
#define AP_CTIME_OPTION_COMPACT 0x2
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* convert a recent time to its human readable components in local timezone
|
|
Packit |
90a5c9 |
* @param tm the exploded time
|
|
Packit |
90a5c9 |
* @param t the time to explode: MUST be within the last
|
|
Packit |
90a5c9 |
* AP_TIME_RECENT_THRESHOLD seconds
|
|
Packit |
90a5c9 |
* @note This is a faster alternative to apr_time_exp_lt that uses
|
|
Packit |
90a5c9 |
* a cache of pre-exploded time structures. It is useful for things
|
|
Packit |
90a5c9 |
* that need to explode the current time multiple times per second,
|
|
Packit |
90a5c9 |
* like loggers.
|
|
Packit |
90a5c9 |
* @return APR_SUCCESS iff successful
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm,
|
|
Packit |
90a5c9 |
apr_time_t t);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* convert a recent time to its human readable components in GMT timezone
|
|
Packit |
90a5c9 |
* @param tm the exploded time
|
|
Packit |
90a5c9 |
* @param t the time to explode: MUST be within the last
|
|
Packit |
90a5c9 |
* AP_TIME_RECENT_THRESHOLD seconds
|
|
Packit |
90a5c9 |
* @note This is a faster alternative to apr_time_exp_gmt that uses
|
|
Packit |
90a5c9 |
* a cache of pre-exploded time structures. It is useful for things
|
|
Packit |
90a5c9 |
* that need to explode the current time multiple times per second,
|
|
Packit |
90a5c9 |
* like loggers.
|
|
Packit |
90a5c9 |
* @return APR_SUCCESS iff successful
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm,
|
|
Packit |
90a5c9 |
apr_time_t t);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* format a recent timestamp in the ctime() format.
|
|
Packit |
90a5c9 |
* @param date_str String to write to.
|
|
Packit |
90a5c9 |
* @param t the time to convert
|
|
Packit |
90a5c9 |
* @note Consider using ap_recent_ctime_ex instead.
|
|
Packit |
90a5c9 |
* @return APR_SUCCESS iff successful
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* format a recent timestamp in an extended ctime() format.
|
|
Packit |
90a5c9 |
* @param date_str String to write to.
|
|
Packit |
90a5c9 |
* @param t the time to convert
|
|
Packit |
90a5c9 |
* @param option Additional formatting options (AP_CTIME_OPTION_*).
|
|
Packit |
90a5c9 |
* @param len Pointer to an int containing the length of the provided buffer.
|
|
Packit |
90a5c9 |
* On successful return it contains the number of bytes written to the
|
|
Packit |
90a5c9 |
* buffer.
|
|
Packit |
90a5c9 |
* @return APR_SUCCESS iff successful, APR_ENOMEM if buffer was to short.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t,
|
|
Packit |
90a5c9 |
int option, int *len);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* format a recent timestamp in the RFC822 format
|
|
Packit |
90a5c9 |
* @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
|
|
Packit |
90a5c9 |
* @param t the time to convert
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef __cplusplus
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#endif /* !APACHE_UTIL_TIME_H */
|
|
Packit |
90a5c9 |
/** @} */
|