mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00: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
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)
|
static time_t tm_to_time(struct tm* tm, long timezone_adjust_seconds)
|
||||||
{
|
{
|
||||||
int days = 0;
|
int days = 0;
|
||||||
if (tm->tm_year >= 70) {
|
for (int year = 70; year < tm->tm_year; ++year)
|
||||||
for (int year = 70; year < tm->tm_year; ++year)
|
days += 365 + __is_leap_year(1900 + year);
|
||||||
days += 365 + __is_leap_year(1900 + year);
|
for (int year = tm->tm_year; year < 70; ++year)
|
||||||
} else {
|
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;
|
tm->tm_yday = tm->tm_mday - 1;
|
||||||
// FIXME: What if tm->tm_mon < 0 or tm->tm_mon > 12?
|
// FIXME: What if tm->tm_mon < 0 or tm->tm_mon > 12?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue