From 80bea4a0d58178e3077bc320282d4cdf07e9c1ca Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 22 Feb 2021 19:14:21 -0800 Subject: [PATCH] [libc] [Obvious] Fix. --- libc/src/time/mktime.cpp | 5 ++++- libc/src/time/time_utils.h | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/src/time/mktime.cpp b/libc/src/time/mktime.cpp index 3e0d06f..a352cc6 100644 --- a/libc/src/time/mktime.cpp +++ b/libc/src/time/mktime.cpp @@ -16,6 +16,9 @@ namespace __llvm_libc { using __llvm_libc::time_utils::TimeConstants; +static constexpr int NonLeapYearDaysInMonth[] = {31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; + // Returns number of years from (1, year). static constexpr int64_t getNumOfLeapYearsBefore(int64_t year) { return (year / 4) - (year / 100) + (year / 400); @@ -198,7 +201,7 @@ LLVM_LIBC_FUNCTION(time_t, mktime, (struct tm * tm_out)) { // Calculate total number of days based on the month and the day (tm_mday). int64_t totalDays = tm_out->tm_mday - 1; for (int64_t i = 0; i < month; ++i) - totalDays += TimeConstants::NonLeapYearDaysInMonth[i]; + totalDays += NonLeapYearDaysInMonth[i]; // Add one day if it is a leap year and the month is after February. if (tmYearIsLeap && month > 1) totalDays++; diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h index 00cc399..48bbf7a 100644 --- a/libc/src/time/time_utils.h +++ b/libc/src/time/time_utils.h @@ -50,9 +50,6 @@ struct TimeConstants { // susceptible to the Year 2038 problem. static constexpr int EndOf32BitEpochYear = 2038; - static constexpr int NonLeapYearDaysInMonth[] = {31, 28, 31, 30, 31, 30, 30, - 31, 31, 30, 31, 30, 31}; - static constexpr time_t OutOfRangeReturnValue = -1; }; -- 2.7.4