From 54efca802db8d494bef14add77ecefaa574f6d85 Mon Sep 17 00:00:00 2001 From: yc Date: Mon, 29 Apr 2024 09:16:19 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20/date.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yc --- cgi/date.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cgi/date.c diff --git a/cgi/date.c b/cgi/date.c new file mode 100644 index 0000000..fac4f6d --- /dev/null +++ b/cgi/date.c @@ -0,0 +1,18 @@ +#include +#include +#include +int main() { + time_t t = time(NULL); + if (t == -1) { + perror("time"); + return 1; + } + struct tm *tm = localtime(&t); + if (tm == NULL) { + perror("localtime"); + return 1; + } + printf("Content-Type: text/plain\n\n"); + printf("%d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); + return 0; +}