Add "date" command

This commit is contained in:
Mark 2020-01-15 17:01:50 +02:00
parent 21c426a133
commit 608037d259
2 changed files with 18 additions and 1 deletions

View File

@ -10,7 +10,8 @@ HDRS=$(shell find $(S) -type f -name "*.h")
STAGE_BIN=$(STAGE)/init \
$(STAGE)/bin/hexd \
$(STAGE)/bin/ls \
$(STAGE)/bin/reboot
$(STAGE)/bin/reboot \
$(STAGE)/bin/date
usr_CFLAGS=-msse \
-msse2 \

16
core/bin/date.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv) {
// Ignore arguments
struct timeval tv0;
gettimeofday(&tv0, NULL);
struct tm tm0;
gmtime_r(&tv0.tv_sec, &tm0);
printf("%04u-%02u-%02u %02u:%02u:%02u\n",
tm0.tm_year, tm0.tm_mon, tm0.tm_mday,
tm0.tm_hour, tm0.tm_min, tm0.tm_sec);
return 0;
}