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