[libc-commits] [libc] 80bea4a - [libc] [Obvious] Fix.
Raman Tenneti via libc-commits
libc-commits at lists.llvm.org
Mon Feb 22 19:16:17 PST 2021
Author: Raman Tenneti
Date: 2021-02-22T19:15:35-08:00
New Revision: 80bea4a0d58178e3077bc320282d4cdf07e9c1ca
URL: https://github.com/llvm/llvm-project/commit/80bea4a0d58178e3077bc320282d4cdf07e9c1ca
DIFF: https://github.com/llvm/llvm-project/commit/80bea4a0d58178e3077bc320282d4cdf07e9c1ca.diff
LOG: [libc] [Obvious] Fix.
Added:
Modified:
libc/src/time/mktime.cpp
libc/src/time/time_utils.h
Removed:
################################################################################
diff --git a/libc/src/time/mktime.cpp b/libc/src/time/mktime.cpp
index 3e0d06f96415..a352cc60dbe9 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 00cc3991a086..48bbf7afca19 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;
};
More information about the libc-commits
mailing list