add: date cmd to shell
This commit is contained in:
parent
c7545d5fc6
commit
ef75ad874d
@ -53,6 +53,7 @@ typedef enum {
|
||||
ECHO,
|
||||
COLOR,
|
||||
MERDELLA,
|
||||
DATE,
|
||||
ERROR
|
||||
} CMD_TOK;
|
||||
|
||||
@ -60,3 +61,4 @@ void shell_init(void);
|
||||
void reboot(void);
|
||||
void halt(void);
|
||||
void print_stack(void);
|
||||
void date(void);
|
||||
|
22
src/shell/date.c
Normal file
22
src/shell/date.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include "kprintf.h"
|
||||
#include "rtc.h"
|
||||
|
||||
void date()
|
||||
{
|
||||
static const char *months[12] = {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December" };
|
||||
struct rtc_date date = get_date();
|
||||
|
||||
kprintf(0, "%s. %d %s. %d %d:%d:%d\n", "mer", date.day, months[date.month], date.year, date.hour, date.minute, date.second);
|
||||
}
|
@ -39,6 +39,8 @@ static CMD_TOK find_command(char *line)
|
||||
command = COLOR;
|
||||
else if (!strcmp(line, "merdella"))
|
||||
command = MERDELLA;
|
||||
else if (!strcmp(line, "date"))
|
||||
command = DATE;
|
||||
else
|
||||
kprintf(0, "invalid command: %s\n", line);
|
||||
if (uwu)
|
||||
@ -120,6 +122,9 @@ void shell_init(void)
|
||||
"by Targon (/)\n");
|
||||
break;
|
||||
}
|
||||
case DATE:
|
||||
date();
|
||||
break;
|
||||
case ERROR:
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user