1
{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
* @brief APR Time Library
23
#include "apr_pools.h"
24
#include "apr_errno.h"}
27
* @defgroup apr_time Time Routines
32
//APR_DECLARE_DATA extern const char apr_month_snames[12][4];
34
//APR_DECLARE_DATA extern const char apr_day_snames[7][4];
37
{ number of microseconds since 00:00:00 january 1, 1970 UTC }
39
apr_time_t = apr_int64_t;
40
Papr_time_t = ^apr_time_t;
43
{ mechanism to properly type apr_time_t literals }
44
//#define APR_TIME_C(val) APR_INT64_C(val)
46
{ mechanism to properly print apr_time_t values }
47
// APR_TIME_T_FMT = APR_INT64_T_FMT;
49
{ intervals for I/O timeouts, in microseconds }
50
apr_interval_time_t = apr_int64_t;
51
Papr_interval_time_t = ^apr_interval_time_t;
52
{ short interval for I/O timeouts, in microseconds }
53
apr_short_interval_time_t = apr_int32_t;
55
{ number of microseconds per second }
56
// APR_USEC_PER_SEC APR_TIME_C(1000000)
58
{ @return apr_time_t as a second }
59
//#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC)
61
{ @return apr_time_t as a usec }
62
//#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC)
64
{ @return apr_time_t as a msec }
65
//#define apr_time_msec(time) (((time) / 1000) % 1000)
67
{ @return apr_time_t as a msec }
68
//#define apr_time_as_msec(time) ((time) / 1000)
70
{ @return a second as an apr_time_t }
71
//#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC)
73
{ @return a second and usec combination as an apr_time_t }
74
//#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \
75
// + (apr_time_t)(usec))
78
* @return the current time
80
function apr_time_now: apr_time_t;
81
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
82
external LibAPR name LibNamePrefix + 'apr_time_now' + LibSuff0;
84
{ @see apr_time_exp_t }
86
Papr_time_exp_t = ^apr_time_exp_t;
89
* a structure similar to ANSI struct tm with the following differences:
90
* - tm_usec isn't an ANSI field
91
* - tm_gmtoff isn't an ANSI field (it's a bsdism)
93
apr_time_exp_t = record
94
{ microseconds past tm_sec }
96
{ (0-61) seconds past tm_min }
98
{ (0-59) minutes past tm_hour }
100
{ (0-23) hours past midnight }
101
tm_hour: apr_int32_t;
102
{ (1-31) day of the month }
103
tm_mday: apr_int32_t;
104
{ (0-11) month of the year }
107
tm_year: apr_int32_t;
108
{ (0-6) days since sunday }
109
tm_wday: apr_int32_t;
110
{ (0-365) days since jan 1 }
111
tm_yday: apr_int32_t;
112
{ daylight saving time }
113
tm_isdst: apr_int32_t;
114
{ seconds east of UTC }
115
tm_gmtoff: apr_int32_t;
119
* convert an ansi time_t to an apr_time_t
120
* @param result the resulting apr_time_t
121
* @param input the time_t to convert
123
function apr_time_ansi_put(result: Papr_time_t;
124
input: time_t): apr_status_t;
125
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
126
external LibAPR name LibNamePrefix + 'apr_time_ansi_put' + LibSuff8;
129
* convert a time to its human readable components using an offset
131
* @param result the exploded time
132
* @param input the time to explode
133
* @param offs the number of seconds offset to apply
135
function apr_time_exp_tz(result: Papr_time_exp_t;
136
input: apr_time_t; offs: apr_int32_t): apr_status_t;
137
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
138
external LibAPR name LibNamePrefix + 'apr_time_exp_tz' + LibSuff16;
140
{ @deprecated @see apr_time_exp_tz }
141
function apr_explode_time(result: Papr_time_exp_t;
142
input: apr_time_t; offs: apr_int32_t): apr_status_t;
143
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
144
external LibAPR name LibNamePrefix + 'apr_explode_time' + LibSuff16;
147
* convert a time to its human readable components in GMT timezone
148
* @param result the exploded time
149
* @param input the time to explode
151
function apr_time_exp_gmt(result: Papr_time_exp_t;
152
input: apr_time_t): apr_status_t;
153
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
154
external LibAPR name LibNamePrefix + 'apr_time_exp_gmt' + LibSuff12;
157
* convert a time to its human readable components in local timezone
158
* @param result the exploded time
159
* @param input the time to explode
161
function apr_time_exp_lt(result: Papr_time_exp_t;
162
input: apr_time_t): apr_status_t;
163
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
164
external LibAPR name LibNamePrefix + 'apr_time_exp_lt' + LibSuff12;
166
{ @deprecated @see apr_time_exp_lt }
167
function apr_explode_localtime(result: Papr_time_exp_t;
168
input: apr_time_t): apr_status_t;
169
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
170
external LibAPR name LibNamePrefix + 'apr_explode_localtime' + LibSuff12;
173
* Convert time value from human readable format to a numeric apr_time_t
174
* e.g. elapsed usec since epoch
175
* @param result the resulting imploded time
176
* @param input the input exploded time
178
function apr_time_exp_get(result: Papr_time_t;
179
input: Papr_time_exp_t): apr_status_t;
180
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
181
external LibAPR name LibNamePrefix + 'apr_time_exp_get' + LibSuff8;
184
* Convert time value from human readable format to a numeric apr_time_t that
185
* always represents GMT
186
* @param result the resulting imploded time
187
* @param input the input exploded time
189
function apr_time_exp_gmt_get(result: Papr_time_t;
190
input: Papr_time_exp_t): apr_status_t;
191
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
192
external LibAPR name LibNamePrefix + 'apr_time_exp_gmt_get' + LibSuff8;
194
{ @deprecated @see apr_time_exp_gmt_get }
195
function apr_implode_gmt(result: Papr_time_t;
196
input: Papr_time_exp_t): apr_status_t;
197
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
198
external LibAPR name LibNamePrefix + 'apr_implode_gmt' + LibSuff8;
201
* Sleep for the specified number of micro-seconds.
202
* @param t desired amount of time to sleep.
203
* @warning May sleep for longer than the specified time.
205
procedure apr_sleep(t: apr_interval_time_t);
206
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
207
external LibAPR name LibNamePrefix + 'apr_sleep' + LibSuff8;
209
{ length of a RFC822 Date }
210
const APR_RFC822_DATE_LEN = (30);
212
* apr_rfc822_date formats dates in the RFC822
213
* format in an efficient manner. It is a fixed length
214
* format which requires the indicated amount of storage,
215
* including the trailing null byte.
216
* @param date_str String to write to.
217
* @param t the time to convert
219
function apr_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t;
220
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
221
external LibAPR name LibNamePrefix + 'apr_rfc822_date' + LibSuff12;
223
{ length of a CTIME date }
224
const APR_CTIME_LEN = (25);
226
* apr_ctime formats dates in the ctime() format
227
* in an efficient manner. it is a fixed length format
228
* and requires the indicated amount of storage including
229
* the trailing null byte.
230
* Unlike ANSI/ISO C ctime(), apr_ctime() does not include
231
* a \n at the end of the string.
232
* @param date_str String to write to.
233
* @param t the time to convert
235
function apr_ctime(date_str: PChar; t: apr_time_t): apr_status_t;
236
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
237
external LibAPR name LibNamePrefix + 'apr_ctime' + LibSuff12;
240
* formats the exploded time according to the format specified
241
* @param s string to write to
242
* @param retsize The length of the returned string
243
* @param max The maximum length of the string
244
* @param format The format for the time string
245
* @param tm The time to convert
247
function apr_strftime(s: PChar; retsize: apr_size_t;
248
max: apr_size_t; const format: PChar;
249
tm: Papr_time_exp_t): apr_status_t;
250
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
251
external LibAPR name LibNamePrefix + 'apr_strftime' + LibSuff20;
254
* Improve the clock resolution for the lifetime of the given pool.
255
* Generally this is only desireable on benchmarking and other very
256
* time-sensitive applications, and has no impact on most platforms.
257
* @param p The pool to associate the finer clock resolution
259
procedure apr_time_clock_hires(p: Papr_pool_t);
260
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
261
external LibAPR name LibNamePrefix + 'apr_time_clock_hires' + LibSuff4;