add function format_http_date

pull/37/head
YuQing 2018-10-11 16:33:38 +08:00
parent 660a471b98
commit d27948ed9c
3 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,5 @@
Version 1.40 2018-09-27 Version 1.40 2018-10-11
* add function conn_pool_parse_server_info and conn_pool_load_server_info * add function conn_pool_parse_server_info and conn_pool_load_server_info
* support directive: #@add_annotation, for example: * support directive: #@add_annotation, for example:
#@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf #@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf
@ -7,6 +7,7 @@ Version 1.40 2018-09-27
* add json_parser.[hc] for parse json array and map * add json_parser.[hc] for parse json array and map
* add function fc_strdup * add function fc_strdup
* add function fc_memmem * add function fc_memmem
* add function format_http_date
Version 1.39 2018-07-31 Version 1.39 2018-07-31
* add #@function REPLACE_VARS * add #@function REPLACE_VARS

View File

@ -2811,3 +2811,13 @@ const char *fc_memmem(const string_t *str, const string_t *needle)
return NULL; return NULL;
} }
char *format_http_date(time_t t, BufferInfo *buffer)
{
struct tm tm_info;
gmtime_r(&t, &tm_info);
buffer->length = strftime(buffer->buff, buffer->alloc_size,
"%a, %d %b %Y %H:%M:%S GMT", &tm_info);
return buffer->buff;
}

View File

@ -832,6 +832,14 @@ char *fc_strdup(const char *str, const int len);
*/ */
const char *fc_memmem(const string_t *str, const string_t *needle); const char *fc_memmem(const string_t *str, const string_t *needle);
/** format HTTP Date as: Sat, 11 Mar 2017 21:49:51 GMT
* parameters:
* t: the time to format
* buffer: the buffer
* return: formatted GMT date string
*/
char *format_http_date(time_t t, BufferInfo *buffer);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif