Kernel/BAN: Add weekday to Time structure and get it with RTC
This commit is contained in:
parent
00f230fcb2
commit
171a33bbcd
|
@ -12,6 +12,7 @@ namespace BAN
|
||||||
uint8_t second;
|
uint8_t second;
|
||||||
uint8_t minute;
|
uint8_t minute;
|
||||||
uint8_t hour;
|
uint8_t hour;
|
||||||
|
uint8_t week_day;
|
||||||
uint8_t day;
|
uint8_t day;
|
||||||
uint8_t month;
|
uint8_t month;
|
||||||
int year;
|
int year;
|
||||||
|
@ -24,7 +25,9 @@ namespace BAN::Formatter
|
||||||
|
|
||||||
template<void(*PUTC_LIKE)(char)> void print_argument_impl(const Time& time, const ValueFormat&)
|
template<void(*PUTC_LIKE)(char)> void print_argument_impl(const Time& time, const ValueFormat&)
|
||||||
{
|
{
|
||||||
print<PUTC_LIKE>("{2}:{2}:{2} {2}.{2}.{4}", time.hour, time.minute, time.second, time.day, time.month, time.year);
|
constexpr const char* week_days[] { "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||||
|
constexpr const char* months[] { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
|
print<PUTC_LIKE>("{} {} {} {}:{}:{} GMT+0 {}", week_days[time.week_day], months[time.month], time.day, time.hour, time.minute, time.second, time.year);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -38,6 +38,7 @@ namespace RTC
|
||||||
out.second = get_rtc_register(CMOS_REGISTER_SECOND);
|
out.second = get_rtc_register(CMOS_REGISTER_SECOND);
|
||||||
out.minute = get_rtc_register(CMOS_REGISTER_MINUTE);
|
out.minute = get_rtc_register(CMOS_REGISTER_MINUTE);
|
||||||
out.hour = get_rtc_register(CMOS_REGISTER_HOUR);
|
out.hour = get_rtc_register(CMOS_REGISTER_HOUR);
|
||||||
|
out.week_day = get_rtc_register(CMOS_REGISTER_WEEK_DAY);
|
||||||
out.day = get_rtc_register(CMOS_REGISTER_DAY);
|
out.day = get_rtc_register(CMOS_REGISTER_DAY);
|
||||||
out.month = get_rtc_register(CMOS_REGISTER_MONTH);
|
out.month = get_rtc_register(CMOS_REGISTER_MONTH);
|
||||||
out.year = get_rtc_register(CMOS_REGISTER_YEAR);
|
out.year = get_rtc_register(CMOS_REGISTER_YEAR);
|
||||||
|
@ -68,6 +69,7 @@ namespace RTC
|
||||||
time.second = (time.second & 0x0F) + ((time.second / 16) * 10);
|
time.second = (time.second & 0x0F) + ((time.second / 16) * 10);
|
||||||
time.minute = (time.minute & 0x0F) + ((time.minute / 16) * 10);
|
time.minute = (time.minute & 0x0F) + ((time.minute / 16) * 10);
|
||||||
time.hour = ((time.hour & 0x0F) + (((time.hour & 0x70) / 16) * 10) ) | (time.hour & 0x80);
|
time.hour = ((time.hour & 0x0F) + (((time.hour & 0x70) / 16) * 10) ) | (time.hour & 0x80);
|
||||||
|
time.week_day = (time.week_day & 0x0F) + ((time.week_day / 16) * 10);
|
||||||
time.day = (time.day & 0x0F) + ((time.day / 16) * 10);
|
time.day = (time.day & 0x0F) + ((time.day / 16) * 10);
|
||||||
time.month = (time.month & 0x0F) + ((time.month / 16) * 10);
|
time.month = (time.month & 0x0F) + ((time.month / 16) * 10);
|
||||||
time.year = (time.year & 0x0F) + ((time.year / 16) * 10);
|
time.year = (time.year & 0x0F) + ((time.year / 16) * 10);
|
||||||
|
|
Loading…
Reference in New Issue