[libc] [Obvious] Fix.
authorRaman Tenneti <rtenneti@google.com>
Tue, 23 Feb 2021 03:14:21 +0000 (19:14 -0800)
committerRaman Tenneti <rtenneti@google.com>
Tue, 23 Feb 2021 03:15:35 +0000 (19:15 -0800)
libc/src/time/mktime.cpp
libc/src/time/time_utils.h

index 3e0d06f..a352cc6 100644 (file)
@@ -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++;
index 00cc399..48bbf7a 100644 (file)
@@ -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;
 };