diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-22 22:13:18 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-23 10:42:37 +0200 |
commit | fc28c9b085380240210a9b623a12232bf33c787b (patch) | |
tree | e03a4e384b489d165dd1716c81965c650848918d | |
parent | cec467fe3557c4d8ba980b951fcc971f165abdb6 (diff) | |
download | serenity-fc28c9b085380240210a9b623a12232bf33c787b.zip |
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.
-rw-r--r-- | Libraries/LibC/time.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Libraries/LibC/time.cpp b/Libraries/LibC/time.cpp index 634bd21621..e06c79a6a7 100644 --- a/Libraries/LibC/time.cpp +++ b/Libraries/LibC/time.cpp @@ -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? |