Browse Source

[multiple] strftime %F and %T

strftime %F for %Y-%m-%d, and %T for %H:%M:%S
master
Glenn Strauss 9 months ago
parent
commit
a6d1dccad3
  1. 2
      src/h2.c
  2. 2
      src/http-header-glue.c
  3. 4
      src/log.c
  4. 4
      src/mod_accesslog.c
  5. 4
      src/mod_dirlisting.c
  6. 2
      src/mod_expire.c
  7. 2
      src/mod_ssi.c
  8. 2
      src/mod_status.c
  9. 4
      src/mod_webdav.c
  10. 2
      src/response.c

2
src/h2.c

@ -1963,7 +1963,7 @@ h2_send_headers (request_st * const r, connection * const con)
if (!light_btst(r->resp_htags, HTTP_HEADER_DATE)) {
/* HTTP/1.1 and later requires a Date: header */
/* "date: " 6-chars + 30-chars for "%a, %d %b %Y %H:%M:%S GMT" + '\0' */
/* "date: " 6-chars + 30-chars for "%a, %d %b %Y %T GMT" + '\0' */
static time_t tlast = 0;
static char tstr[36] = "date: ";

2
src/http-header-glue.c

@ -140,7 +140,7 @@ struct mtime_cache_type {
};
static struct mtime_cache_type mtime_cache[MTIME_CACHE_MAX];
static char mtime_cache_str[MTIME_CACHE_MAX][30];
/* 30-chars for "%a, %d %b %Y %H:%M:%S GMT" */
/* 30-chars for "%a, %d %b %Y %T GMT" */
void strftime_cache_reset(void) {
for (int i = 0; i < MTIME_CACHE_MAX; ++i) {

4
src/log.c

@ -70,7 +70,7 @@ ssize_t write_all(int fd, const void * const buf, size_t count) {
static int log_buffer_prepare(const log_error_st *errh, const char *filename, unsigned int line, buffer *b) {
static time_t tlast;
static uint32_t tlen;
static char tstr[24]; /* 20 "%Y-%m-%d %H:%M:%S" incl '\0' +3 ": (" */
static char tstr[24]; /* 20 "%F %T" incl '\0' +3 ": (" */
switch(errh->errorlog_mode) {
case ERRORLOG_PIPE:
case ERRORLOG_FILE:
@ -81,7 +81,7 @@ static int log_buffer_prepare(const log_error_st *errh, const char *filename, un
struct tm tm;
tlast = log_epoch_secs;
tlen = (uint32_t)
strftime(tstr, sizeof(tstr), "%Y-%m-%d %H:%M:%S",
strftime(tstr, sizeof(tstr), "%F %T",
localtime_r(&tlast, &tm));
tstr[ tlen] = ':';
tstr[++tlen] = ' ';

4
src/mod_accesslog.c

@ -891,11 +891,11 @@ static int log_access_record (const request_st * const r, buffer * const b, form
buffer_clear(ts_accesslog_str);
#if defined(HAVE_STRUCT_TM_GMTOFF)
buffer_append_strftime(ts_accesslog_str,
fmt ? fmt : "[%d/%b/%Y:%H:%M:%S %z]",
fmt ? fmt : "[%d/%b/%Y:%T %z]",
localtime_r(&t, &tm));
#else /* HAVE_STRUCT_TM_GMTOFF */
buffer_append_strftime(ts_accesslog_str,
fmt ? fmt : "[%d/%b/%Y:%H:%M:%S +0000]",
fmt ? fmt : "[%d/%b/%Y:%T +0000]",
gmtime_r(&t, &tm));
#endif /* HAVE_STRUCT_TM_GMTOFF */
buffer_append_string_buffer(b, ts_accesslog_str);

4
src/mod_dirlisting.c

@ -961,7 +961,7 @@ static int http_list_directory(request_st * const r, plugin_data * const p) {
buffer_append_string_len(out, CONST_STR_LEN("/\">"));
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML);
buffer_append_string_len(out, CONST_STR_LEN("</a>/</td><td class=\"m\">"));
buffer_append_strftime(out, "%Y-%b-%d %H:%M:%S", localtime_r(&tmp->mtime, &tm));
buffer_append_strftime(out, "%Y-%b-%d %T", localtime_r(&tmp->mtime, &tm));
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>\n"));
free(tmp);
@ -1005,7 +1005,7 @@ static int http_list_directory(request_st * const r, plugin_data * const p) {
buffer_append_string_len(out, CONST_STR_LEN("\">"));
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML);
buffer_append_string_len(out, CONST_STR_LEN("</a></td><td class=\"m\">"));
buffer_append_strftime(out, "%Y-%b-%d %H:%M:%S", localtime_r(&tmp->mtime, &tm));
buffer_append_strftime(out, "%Y-%b-%d %T", localtime_r(&tmp->mtime, &tm));
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">"));
buffer_append_string(out, sizebuf);
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"t\">"));

2
src/mod_expire.c

@ -318,7 +318,7 @@ REQUEST_FUNC(mod_expire_handler) {
/* HTTP/1.0 */
vb = http_header_response_set_ptr(r, HTTP_HEADER_EXPIRES,
CONST_STR_LEN("Expires"));
buffer_append_strftime(vb, "%a, %d %b %Y %H:%M:%S GMT", gmtime_r(&expires,&tm));
buffer_append_strftime(vb, "%a, %d %b %Y %T GMT", gmtime_r(&expires,&tm));
/* HTTP/1.1 */
vb = http_header_response_set_ptr(r, HTTP_HEADER_CACHE_CONTROL,

2
src/mod_ssi.c

@ -185,7 +185,7 @@ static int build_ssi_cgi_vars(request_st * const r, handler_ctx * const p) {
static const char * mod_ssi_timefmt (handler_ctx * const hctx) {
return buffer_string_is_empty(hctx->timefmt)
? "%a, %d %b %Y %H:%M:%S %Z"
? "%a, %d %b %Y %T %Z"
: hctx->timefmt->ptr;
}

2
src/mod_status.c

@ -475,7 +475,7 @@ static handler_t mod_status_handle_server_status_html(server *srv, request_st *
ts = srv->startup_ts;
struct tm tm;
buffer_append_strftime(b, "%Y-%m-%d %H:%M:%S", localtime_r(&ts, &tm));
buffer_append_strftime(b, "%F %T", localtime_r(&ts, &tm));
buffer_append_string_len(b, CONST_STR_LEN("</td></tr>\n"));

4
src/mod_webdav.c

@ -3081,7 +3081,7 @@ webdav_propfind_live_props (const webdav_propfind_bufs * const restrict pb,
if (__builtin_expect( (NULL != gmtime_r(&pb->st.st_ctime, &tm)), 1)) {
buffer_append_string_len(b, CONST_STR_LEN(
"<D:creationdate ns0:dt=\"dateTime.tz\">"));
buffer_append_strftime(b, "%Y-%m-%dT%TZ", &tm));
buffer_append_strftime(b, "%FT%TZ", &tm));
buffer_append_string_len(b, CONST_STR_LEN(
"</D:creationdate>"));
}
@ -3177,7 +3177,7 @@ webdav_propfind_live_props (const webdav_propfind_bufs * const restrict pb,
if (__builtin_expect( (NULL != gmtime_r(&pb->st.st_mtime, &tm)), 1)) {
buffer_append_string_len(b, CONST_STR_LEN(
"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"));
buffer_append_strftime(b, "%a, %d %b %Y %H:%M:%S GMT", &tm);
buffer_append_strftime(b, "%a, %d %b %Y %T GMT", &tm);
buffer_append_string_len(b, CONST_STR_LEN(
"</D:getlastmodified>"));
}

2
src/response.c

@ -136,7 +136,7 @@ http_response_write_header (request_st * const r)
if (!light_btst(r->resp_htags, HTTP_HEADER_DATE)) {
/* HTTP/1.1 and later requires a Date: header */
/* "\r\nDate: " 8-chars + 30-chars "%a, %d %b %Y %H:%M:%S GMT" + '\0' */
/* "\r\nDate: " 8-chars + 30-chars "%a, %d %b %Y %T GMT" + '\0' */
static time_t tlast = 0;
static char tstr[40] = "\r\nDate: ";

Loading…
Cancel
Save