mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
Kernel: Minor tweak to now() computation
Make sure the expression is evaluated as time_t so that it does the right thing after 2037, and factor things so that the constants look less magical.
This commit is contained in:
parent
c85e679e2d
commit
4dfe97f9ae
Notes:
sideshowbarker
2024-07-19 03:08:35 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/4dfe97f9ae8 Pull-request: https://github.com/SerenityOS/serenity/pull/3307
1 changed files with 2 additions and 5 deletions
|
@ -104,11 +104,8 @@ time_t now()
|
|||
|
||||
ASSERT(year >= 2018);
|
||||
|
||||
return years_to_days_since_epoch(year) * 86400
|
||||
+ day_of_year(year, month, day) * 86400
|
||||
+ hour * 3600
|
||||
+ minute * 60
|
||||
+ second;
|
||||
time_t days_since_epoch = years_to_days_since_epoch(year) + day_of_year(year, month, day);
|
||||
return ((days_since_epoch * 24 + hour) * 60 + minute) * 60 + second;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue