mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:07:40 +00:00
Kernel: Computing the boot timestamp was a bit broken.
This commit is contained in:
parent
3ae75e04ec
commit
932836e3c7
1 changed files with 18 additions and 13 deletions
|
@ -33,23 +33,26 @@ inline bool is_leap_year(unsigned year)
|
||||||
|
|
||||||
static unsigned days_in_months_since_start_of_year(unsigned month, unsigned year)
|
static unsigned days_in_months_since_start_of_year(unsigned month, unsigned year)
|
||||||
{
|
{
|
||||||
|
unsigned days = 0;
|
||||||
switch (month) {
|
switch (month) {
|
||||||
case 11: return 30;
|
case 11: days += 30;
|
||||||
case 10: return 31;
|
case 10: days += 31;
|
||||||
case 9: return 30;
|
case 9: days += 30;
|
||||||
case 8: return 31;
|
case 8: days += 31;
|
||||||
case 7: return 31;
|
case 7: days += 31;
|
||||||
case 6: return 30;
|
case 6: days += 30;
|
||||||
case 5: return 31;
|
case 5: days += 31;
|
||||||
case 4: return 30;
|
case 4: days += 30;
|
||||||
case 3: return 31;
|
case 3: days += 31;
|
||||||
case 2:
|
case 2:
|
||||||
if (is_leap_year(year))
|
if (is_leap_year(year))
|
||||||
return 29;
|
days += 29;
|
||||||
return 28;
|
else
|
||||||
case 1: return 31;
|
days += 28;
|
||||||
default: return 0;
|
case 1: days += 31;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned days_in_years_since_epoch(unsigned year)
|
static unsigned days_in_years_since_epoch(unsigned year)
|
||||||
|
@ -88,6 +91,8 @@ time_t now()
|
||||||
unsigned year, month, day, hour, minute, second;
|
unsigned year, month, day, hour, minute, second;
|
||||||
read_registers(year, month, day, hour, minute, second);
|
read_registers(year, month, day, hour, minute, second);
|
||||||
|
|
||||||
|
kprintf("year: %d, month: %d, day: %d\n", year, month, day);
|
||||||
|
|
||||||
ASSERT(year >= 2018);
|
ASSERT(year >= 2018);
|
||||||
|
|
||||||
return days_in_years_since_epoch(year - 1) * 86400
|
return days_in_years_since_epoch(year - 1) * 86400
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue