mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibC: Slightly tweak tm_to_time
Only one of these loops runs even without the outer if, so omit it. No behavior change, and a bit shorter and arguably a bit clearer.
This commit is contained in:
parent
cec467fe35
commit
fc28c9b085
Notes:
sideshowbarker
2024-07-19 03:16:14 +09:00
Author: https://github.com/nico
Commit: fc28c9b085
Pull-request: https://github.com/SerenityOS/serenity/pull/3269
1 changed files with 4 additions and 7 deletions
|
@ -96,13 +96,10 @@ static void time_to_tm(struct tm* tm, time_t t)
|
|||
static time_t tm_to_time(struct tm* tm, long timezone_adjust_seconds)
|
||||
{
|
||||
int days = 0;
|
||||
if (tm->tm_year >= 70) {
|
||||
for (int year = 70; year < tm->tm_year; ++year)
|
||||
days += 365 + __is_leap_year(1900 + year);
|
||||
} else {
|
||||
for (int year = tm->tm_year; year < 70; ++year)
|
||||
days -= 365 + __is_leap_year(1900 + year);
|
||||
}
|
||||
for (int year = 70; year < tm->tm_year; ++year)
|
||||
days += 365 + __is_leap_year(1900 + year);
|
||||
for (int year = tm->tm_year; year < 70; ++year)
|
||||
days -= 365 + __is_leap_year(1900 + year);
|
||||
|
||||
tm->tm_yday = tm->tm_mday - 1;
|
||||
// FIXME: What if tm->tm_mon < 0 or tm->tm_mon > 12?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue