Add "date" command
This commit is contained in:
parent
21c426a133
commit
608037d259
3
Makefile
3
Makefile
@ -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
16
core/bin/date.c
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user