From ad50447ec61b2ec7bb227abe3e93715263ef3ee4 Mon Sep 17 00:00:00 2001 From: Behnejad <3690943+behnejad@users.noreply.github.com> Date: Wed, 7 Sep 2022 09:04:15 +0430 Subject: [PATCH 1/2] display file modify date in "%Y/%m/%d %H:%M:%S". adding compile time option to display file modification date as "%Y/%m/%d %H:%M:%S" in http directory indexing. --- src/http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/http.c b/src/http.c index fd06045e..b026f5a0 100644 --- a/src/http.c +++ b/src/http.c @@ -563,7 +563,19 @@ static void printdirentry(const char *name, void *userdata) { } else { mg_snprintf(sz, sizeof(sz), "%lld", (uint64_t) size); } +#if defined(MG_HTTP_LOCALTIME) + char time_str[30]; + struct tm * time_info = localtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); +#elif defined(MG_HTTP_UTC) + char time_str[30]; + struct tm * time_info = gmtime(&t); + strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info); + mg_snprintf(mod, sizeof(mod), "%s", time_str); +#else mg_snprintf(mod, sizeof(mod), "%ld", (unsigned long) t); +#endif n = (int) mg_url_encode(name, strlen(name), path, sizeof(path)); mg_printf(d->c, "