util_time.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. { Copyright 2001-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  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
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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.
  15. }
  16. {#include "apr.h"
  17. #include "apr_time.h"
  18. #include "httpd.h"}
  19. {
  20. * @package Apache date-time handling functions
  21. }
  22. { Maximum delta from the current time, in seconds, for a past time
  23. * to qualify as "recent" for use in the ap_explode_recent_*() functions:
  24. * (Must be a power of two minus one!)
  25. }
  26. const AP_TIME_RECENT_THRESHOLD = 15;
  27. {
  28. * convert a recent time to its human readable components in local timezone
  29. * @param tm the exploded time
  30. * @param t the time to explode: MUST be within the last
  31. * AP_TIME_RECENT_THRESHOLD seconds
  32. * @note This is a faster alternative to apr_explode_localtime that uses
  33. * a cache of pre-exploded time structures. It is useful for things
  34. * that need to explode the current time multiple times per second,
  35. * like loggers.
  36. * @return APR_SUCCESS iff successful
  37. }
  38. function ap_explode_recent_localtime(tm: Papr_time_exp_t; t: apr_time_t): apr_status_t;
  39. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  40. external LibHTTPD name LibNamePrefix + 'ap_explode_recent_localtime' + LibSuff12;
  41. {
  42. * convert a recent time to its human readable components in GMT timezone
  43. * @param tm the exploded time
  44. * @param t the time to explode: MUST be within the last
  45. * AP_TIME_RECENT_THRESHOLD seconds
  46. * @note This is a faster alternative to apr_time_exp_gmt that uses
  47. * a cache of pre-exploded time structures. It is useful for things
  48. * that need to explode the current time multiple times per second,
  49. * like loggers.
  50. * @return APR_SUCCESS iff successful
  51. }
  52. function ap_explode_recent_gmt(tm: Papr_time_exp_t; t: apr_time_t): apr_status_t;
  53. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  54. external LibHTTPD name LibNamePrefix + 'ap_explode_recent_gmt' + LibSuff12;
  55. {
  56. * format a recent timestamp in the ctime() format.
  57. * @param date_str String to write to.
  58. * @param t the time to convert
  59. }
  60. function ap_recent_ctime(date_str: PChar; t: apr_time_t): apr_status_t;
  61. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  62. external LibHTTPD name LibNamePrefix + 'ap_recent_ctime' + LibSuff12;
  63. {
  64. * format a recent timestamp in the RFC822 format
  65. * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
  66. * @param t the time to convert
  67. }
  68. function ap_recent_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t;
  69. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  70. external LibHTTPD name LibNamePrefix + 'ap_recent_rfc822_date' + LibSuff12;