✨ Add /date.
Signed-off-by: yc <yc@hackclub.app>
This commit is contained in:
parent
1ea5588e41
commit
54efca802d
1 changed files with 18 additions and 0 deletions
18
cgi/date.c
Normal file
18
cgi/date.c
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in a new issue