Merge pull request #1713 from behnejad/master

display file modify date in "%Y/%m/%d %H:%M:%S".
This commit is contained in:
Sergey Lyubka 2022-09-08 08:55:22 +01:00 committed by GitHub
commit 50a2063e45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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_DIRLIST_TIME)
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_DIRLIST_TIME_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,
" <tr><td><a href=\"%.*s%s\">%s%s</a></td>"