[libc-commits] [libc] change the return value type of mktime_internal to time_t (PR #132231)
Mikhail R. Gadelha via libc-commits
libc-commits at lists.llvm.org
Sat Mar 22 08:05:07 PDT 2025
================
@@ -18,29 +18,32 @@ namespace LIBC_NAMESPACE_DECL {
namespace time_utils {
// TODO: clean this up in a followup patch
-int64_t mktime_internal(const tm *tm_out) {
+TMParse mktime_internal(const tm *tm_out) {
// Unlike most C Library functions, mktime doesn't just die on bad input.
// TODO(rtenneti); Handle leap seconds.
int64_t tm_year_from_base = tm_out->tm_year + time_constants::TIME_YEAR_BASE;
// 32-bit end-of-the-world is 03:14:07 UTC on 19 January 2038.
if (sizeof(time_t) == 4 &&
tm_year_from_base >= time_constants::END_OF32_BIT_EPOCH_YEAR) {
- if (tm_year_from_base > time_constants::END_OF32_BIT_EPOCH_YEAR)
- return time_utils::out_of_range();
- if (tm_out->tm_mon > 0)
- return time_utils::out_of_range();
- if (tm_out->tm_mday > 19)
- return time_utils::out_of_range();
- else if (tm_out->tm_mday == 19) {
- if (tm_out->tm_hour > 3)
- return time_utils::out_of_range();
- else if (tm_out->tm_hour == 3) {
- if (tm_out->tm_min > 14)
- return time_utils::out_of_range();
- else if (tm_out->tm_min == 14) {
- if (tm_out->tm_sec > 7)
- return time_utils::out_of_range();
+ if (tm_year_from_base > time_constants::END_OF32_BIT_EPOCH_YEAR) {
----------------
mikhailramalho wrote:
You don't need curly braces for single line `if`s
https://github.com/llvm/llvm-project/pull/132231
More information about the libc-commits
mailing list