add: date cmd to shell
This commit is contained in:
parent
c7545d5fc6
commit
ef75ad874d
@ -53,6 +53,7 @@ typedef enum {
|
|||||||
ECHO,
|
ECHO,
|
||||||
COLOR,
|
COLOR,
|
||||||
MERDELLA,
|
MERDELLA,
|
||||||
|
DATE,
|
||||||
ERROR
|
ERROR
|
||||||
} CMD_TOK;
|
} CMD_TOK;
|
||||||
|
|
||||||
@ -60,3 +61,4 @@ void shell_init(void);
|
|||||||
void reboot(void);
|
void reboot(void);
|
||||||
void halt(void);
|
void halt(void);
|
||||||
void print_stack(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;
|
command = COLOR;
|
||||||
else if (!strcmp(line, "merdella"))
|
else if (!strcmp(line, "merdella"))
|
||||||
command = MERDELLA;
|
command = MERDELLA;
|
||||||
|
else if (!strcmp(line, "date"))
|
||||||
|
command = DATE;
|
||||||
else
|
else
|
||||||
kprintf(0, "invalid command: %s\n", line);
|
kprintf(0, "invalid command: %s\n", line);
|
||||||
if (uwu)
|
if (uwu)
|
||||||
@ -120,6 +122,9 @@ void shell_init(void)
|
|||||||
"by Targon (/)\n");
|
"by Targon (/)\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DATE:
|
||||||
|
date();
|
||||||
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user