|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
|
|
#include <console.h> |
|
|
|
@ -36,6 +37,27 @@ int shell_time(struct console *con, size_t argc, const char **argv) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int shell_set_time(struct console *con, size_t argc, const char **argv) |
|
|
|
|
{ |
|
|
|
|
struct tm now; |
|
|
|
|
time_t time; |
|
|
|
|
|
|
|
|
|
if (argc < 1) { |
|
|
|
|
fprintf(con->fp, "usage: set-time <seconds>\n"); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
time = (time_t)strtoul(argv[0], NULL, 0); |
|
|
|
|
gmtime_r(&time, &now); |
|
|
|
|
rtc_init(&now); |
|
|
|
|
|
|
|
|
|
fprintf(con->fp, "%02d:%02d:%02d %02d-%02d-%d\n", |
|
|
|
|
now.tm_hour, now.tm_min, now.tm_sec, |
|
|
|
|
now.tm_mday, now.tm_mon + 1, now.tm_year + 1900); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int shell_set_date(struct console *con, size_t argc, const char **argv) |
|
|
|
|
{ |
|
|
|
|
struct tm now; |
|
|
|
|