add: date cmd to shell

This commit is contained in:
starnakin 2024-09-18 21:45:18 +02:00
parent c7545d5fc6
commit ef75ad874d
3 changed files with 29 additions and 0 deletions

View File

@ -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
View 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);
}

View File

@ -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: