Time Routines
Overview
// typedefs typedef apr_int64_t apr_time_t; typedef apr_int64_t apr_interval_time_t; typedef apr_int32_t apr_short_interval_time_t; typedef struct apr_time_exp_t apr_time_exp_t; // structs struct apr_time_exp_t; // global variables const char apr_month_snames[12][4]; const char apr_day_snames[7][4]; // global functions apr_time_t apr_time_now(void); apr_status_t apr_time_ansi_put( apr_time_t* result, time_t input ); apr_status_t apr_time_exp_tz( apr_time_exp_t* result, apr_time_t input, apr_int32_t offs ); apr_status_t apr_time_exp_gmt( apr_time_exp_t* result, apr_time_t input ); apr_status_t apr_time_exp_lt( apr_time_exp_t* result, apr_time_t input ); apr_status_t apr_time_exp_get( apr_time_t* result, apr_time_exp_t* input ); apr_status_t apr_time_exp_gmt_get( apr_time_t* result, apr_time_exp_t* input ); void apr_sleep(apr_interval_time_t t); apr_status_t apr_rfc822_date( char* date_str, apr_time_t t ); apr_status_t apr_ctime( char* date_str, apr_time_t t ); apr_status_t apr_strftime( char* s, apr_size_t* retsize, apr_size_t max, const char* format, apr_time_exp_t* tm ); void apr_time_clock_hires(apr_pool_t* p); // macros #define APR_CTIME_LEN #define APR_RFC822_DATE_LEN #define APR_TIME_C(val) #define APR_TIME_T_FMT #define APR_USEC_PER_SEC #define apr_time_as_msec(time) #define apr_time_from_msec(msec) #define apr_time_from_sec(sec) #define apr_time_make( \ sec, \ usec \ ) #define apr_time_msec(time) #define apr_time_sec(time) #define apr_time_usec(time)
Detailed Documentation
Typedefs
typedef apr_int64_t apr_time_t
number of microseconds since 00:00:00 January 1, 1970 UTC
typedef apr_int64_t apr_interval_time_t
intervals for I/O timeouts, in microseconds
typedef apr_int32_t apr_short_interval_time_t
short interval for I/O timeouts, in microseconds
typedef struct apr_time_exp_t apr_time_exp_t
See also:
Global Variables
const char apr_month_snames[12][4]
month names
const char apr_day_snames[7][4]
day names
Global Functions
apr_time_t apr_time_now(void)
Returns:
the current time
apr_status_t apr_time_ansi_put( apr_time_t* result, time_t input )
Convert an ansi time_t to an apr_time_t
Parameters:
result |
the resulting apr_time_t |
input |
the time_t to convert |
apr_status_t apr_time_exp_tz( apr_time_exp_t* result, apr_time_t input, apr_int32_t offs )
Convert a time to its human readable components using an offset from GMT.
Parameters:
result |
the exploded time |
input |
the time to explode |
offs |
the number of seconds offset to apply |
apr_status_t apr_time_exp_gmt( apr_time_exp_t* result, apr_time_t input )
Convert a time to its human readable components (GMT).
Parameters:
result |
the exploded time |
input |
the time to explode |
apr_status_t apr_time_exp_lt( apr_time_exp_t* result, apr_time_t input )
Convert a time to its human readable components in the local timezone.
Parameters:
result |
the exploded time |
input |
the time to explode |
apr_status_t apr_time_exp_get( apr_time_t* result, apr_time_exp_t* input )
Convert time value from human readable format to a numeric apr_time_t (elapsed microseconds since the epoch).
Parameters:
result |
the resulting imploded time |
input |
the input exploded time |
apr_status_t apr_time_exp_gmt_get( apr_time_t* result, apr_time_exp_t* input )
Convert time value from human readable format to a numeric apr_time_t that always represents GMT.
Parameters:
result |
the resulting imploded time |
input |
the input exploded time |
void apr_sleep(apr_interval_time_t t)
Sleep for the specified number of micro-seconds.
Warning
May sleep for longer than the specified time.
Parameters:
t |
desired amount of time to sleep. |
apr_status_t apr_rfc822_date( char* date_str, apr_time_t t )
apr_rfc822_date formats dates in the RFC822 format in an efficient manner. It is a fixed length format which requires APR_RFC822_DATA_LEN bytes of storage, including the trailing NUL terminator.
Parameters:
date_str |
String to write to. |
t |
the time to convert |
apr_status_t apr_ctime( char* date_str, apr_time_t t )
apr_ctime formats dates in the ctime() format in an efficient manner. It is a fixed length format and requires APR_CTIME_LEN bytes of storage including the trailing NUL terminator. Unlike ANSI/ISO C ctime(), apr_ctime() does not include a n at the end of the string.
Parameters:
date_str |
String to write to. |
t |
the time to convert |
apr_status_t apr_strftime( char* s, apr_size_t* retsize, apr_size_t max, const char* format, apr_time_exp_t* tm )
Formats the exploded time according to the format specified
Parameters:
s |
string to write to |
retsize |
The length of the returned string |
max |
The maximum length of the string |
format |
The format for the time string |
tm |
The time to convert |
void apr_time_clock_hires(apr_pool_t* p)
Improve the clock resolution for the lifetime of the given pool. Generally this is only desirable on benchmarking and other very time-sensitive applications, and has no impact on most platforms.
Parameters:
p |
The pool to associate the finer clock resolution |
Macros
#define APR_CTIME_LEN
length of a CTIME date
#define APR_RFC822_DATE_LEN
length of a RFC822 Date
#define APR_TIME_C(val)
mechanism to properly type apr_time_t literals
#define APR_TIME_T_FMT
mechanism to properly print apr_time_t values
#define APR_USEC_PER_SEC
number of microseconds per second
#define apr_time_as_msec(time)
Returns:
apr_time_t as a msec
#define apr_time_from_msec(msec)
Returns:
milliseconds as an apr_time_t
#define apr_time_from_sec(sec)
Returns:
seconds as an apr_time_t
#define apr_time_make( \ sec, \ usec \ )
Returns:
a second and usec combination as an apr_time_t
#define apr_time_msec(time)
Returns:
apr_time_t as a msec
#define apr_time_sec(time)
Returns:
apr_time_t as a second
#define apr_time_usec(time)
Returns:
apr_time_t as a usec