From a6d1dccad37f3d5f116bc209a9eb679286274c7b Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Tue, 23 Mar 2021 11:52:21 -0400 Subject: [PATCH] [multiple] strftime %F and %T strftime %F for %Y-%m-%d, and %T for %H:%M:%S --- src/h2.c | 2 +- src/http-header-glue.c | 2 +- src/log.c | 4 ++-- src/mod_accesslog.c | 4 ++-- src/mod_dirlisting.c | 4 ++-- src/mod_expire.c | 2 +- src/mod_ssi.c | 2 +- src/mod_status.c | 2 +- src/mod_webdav.c | 4 ++-- src/response.c | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/h2.c b/src/h2.c index 09ee2480..9560ab07 100644 --- a/src/h2.c +++ b/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: "; diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 64c68c6c..7d9afcd2 100644 --- a/src/http-header-glue.c +++ b/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) { diff --git a/src/log.c b/src/log.c index 94b18afb..fc1f9d12 100644 --- a/src/log.c +++ b/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] = ' '; diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c index 10b1a0b1..20407a97 100644 --- a/src/mod_accesslog.c +++ b/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); diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c index a7b69635..ed3e2f36 100644 --- a/src/mod_dirlisting.c +++ b/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("/")); - 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("-  Directory\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("")); - 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("")); buffer_append_string(out, sizebuf); buffer_append_string_len(out, CONST_STR_LEN("")); diff --git a/src/mod_expire.c b/src/mod_expire.c index eefa3c1d..a2f42eb8 100644 --- a/src/mod_expire.c +++ b/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, diff --git a/src/mod_ssi.c b/src/mod_ssi.c index fe18242e..779fa22b 100644 --- a/src/mod_ssi.c +++ b/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; } diff --git a/src/mod_status.c b/src/mod_status.c index 787a1ae2..6ca40ce2 100644 --- a/src/mod_status.c +++ b/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("\n")); diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 0378e94e..a5b6b6a8 100644 --- a/src/mod_webdav.c +++ b/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( "")); - buffer_append_strftime(b, "%Y-%m-%dT%TZ", &tm)); + buffer_append_strftime(b, "%FT%TZ", &tm)); buffer_append_string_len(b, CONST_STR_LEN( "")); } @@ -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( "")); - 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( "")); } diff --git a/src/response.c b/src/response.c index e486d6ee..c20834fe 100644 --- a/src/response.c +++ b/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: ";