1414#include " hdr/types/time_t.h"
1515#include " src/__support/CPP/optional.h"
1616#include " src/__support/CPP/string_view.h"
17- #include < stddef.h> // For size_t.
18- #include " hdr/types/time_t.h"
19- #include " src/__support/CPP/limits.h"
20- #include " src/time/time_constants.h"
21- #include < time.h>
2217#include " src/__support/common.h"
2318#include " src/__support/macros/config.h"
2419#include " src/errno/libc_errno.h"
@@ -40,69 +35,6 @@ namespace time_utils {
4035// you must call update_from_seconds for that.
4136cpp::optional<time_t > mktime_internal (const tm *tm_out);
4237
43- enum Month : int {
44- JANUARY,
45- FEBRUARY,
46- MARCH,
47- APRIL,
48- MAY,
49- JUNE,
50- JULY,
51- AUGUST,
52- SEPTEMBER,
53- OCTOBER,
54- NOVEMBER,
55- DECEMBER
56- };
57-
58- struct TimeConstants {
59- static constexpr int SECONDS_PER_MIN = 60 ;
60- static constexpr int MINUTES_PER_HOUR = 60 ;
61- static constexpr int HOURS_PER_DAY = 24 ;
62- static constexpr int DAYS_PER_WEEK = 7 ;
63- static constexpr int MONTHS_PER_YEAR = 12 ;
64- static constexpr int DAYS_PER_NON_LEAP_YEAR = 365 ;
65- static constexpr int DAYS_PER_LEAP_YEAR = 366 ;
66-
67- static constexpr int SECONDS_PER_HOUR = SECONDS_PER_MIN * MINUTES_PER_HOUR;
68- static constexpr int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
69- static constexpr int NUMBER_OF_SECONDS_IN_LEAP_YEAR =
70- DAYS_PER_LEAP_YEAR * SECONDS_PER_DAY;
71-
72- static constexpr int TIME_YEAR_BASE = 1900 ;
73- static constexpr int EPOCH_YEAR = 1970 ;
74- static constexpr int EPOCH_WEEK_DAY = 4 ;
75-
76- // For asctime the behavior is undefined if struct tm's tm_wday or tm_mon are
77- // not within the normal ranges as defined in <time.h>, or if struct tm's
78- // tm_year exceeds {INT_MAX}-1990, or if the below asctime_internal algorithm
79- // would attempt to generate more than 26 bytes of output (including the
80- // terminating null).
81- static constexpr int ASCTIME_BUFFER_SIZE = 256 ;
82- static constexpr int ASCTIME_MAX_BYTES = 26 ;
83-
84- /* 2000-03-01 (mod 400 year, immediately after feb29 */
85- static constexpr int64_t SECONDS_UNTIL2000_MARCH_FIRST =
86- (946684800LL + SECONDS_PER_DAY * (31 + 29 ));
87- static constexpr int WEEK_DAY_OF2000_MARCH_FIRST = 3 ;
88-
89- static constexpr int DAYS_PER400_YEARS =
90- (DAYS_PER_NON_LEAP_YEAR * 400 ) + (400 / 4 ) - 3 ;
91- static constexpr int DAYS_PER100_YEARS =
92- (DAYS_PER_NON_LEAP_YEAR * 100 ) + (100 / 4 ) - 1 ;
93- static constexpr int DAYS_PER4_YEARS = (DAYS_PER_NON_LEAP_YEAR * 4 ) + 1 ;
94-
95- // The latest time that can be represented in this form is 03:14:07 UTC on
96- // Tuesday, 19 January 2038 (corresponding to 2,147,483,647 seconds since the
97- // start of the epoch). This means that systems using a 32-bit time_t type are
98- // susceptible to the Year 2038 problem.
99- static constexpr int END_OF32_BIT_EPOCH_YEAR = 2038 ;
100-
101- static constexpr time_t OUT_OF_RANGE_RETURN_VALUE = -1 ;
102-
103- static constexpr size_t TIMEZONE_SIZE = 128 ;
104- };
105-
10638LIBC_INLINE volatile int file_usage;
10739
10840// Update the "tm" structure's year, month, etc. members from seconds.
@@ -111,6 +43,7 @@ extern int calculate_dst(struct tm *tm);
11143extern void set_dst (struct tm *tm);
11244extern int64_t update_from_seconds (int64_t total_seconds, struct tm *tm, bool local);
11345extern timezone::tzset *get_localtime (struct tm *tm);
46+ extern int64_t update_from_seconds (int64_t total_seconds, struct tm *tm);
11447extern ErrorOr<File *> acquire_file (char *filename);
11548extern void release_file (ErrorOr<File *> error_or_file);
11649extern unsigned char is_dst (struct tm *tm);
0 commit comments