1000a3f0aSЗишан Мирза //===-- Implementation of ctime function ----------------------------------===// 2000a3f0aSЗишан Мирза // 3000a3f0aSЗишан Мирза // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4000a3f0aSЗишан Мирза // See https://llvm.org/LICENSE.txt for license information. 5000a3f0aSЗишан Мирза // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6000a3f0aSЗишан Мирза // 7000a3f0aSЗишан Мирза //===----------------------------------------------------------------------===// 8000a3f0aSЗишан Мирза 9*f9c2377fSMichael Jones #include "src/time/ctime.h" 10000a3f0aSЗишан Мирза #include "src/__support/CPP/limits.h" 11000a3f0aSЗишан Мирза #include "src/__support/common.h" 12000a3f0aSЗишан Мирза #include "src/__support/macros/config.h" 13*f9c2377fSMichael Jones #include "src/time/time_constants.h" 14*f9c2377fSMichael Jones #include "src/time/time_utils.h" 15000a3f0aSЗишан Мирза 16000a3f0aSЗишан Мирза namespace LIBC_NAMESPACE_DECL { 17000a3f0aSЗишан Мирза 18000a3f0aSЗишан Мирза LLVM_LIBC_FUNCTION(char *, ctime, (const time_t *t_ptr)) { 19000a3f0aSЗишан Мирза if (t_ptr == nullptr || *t_ptr > cpp::numeric_limits<int32_t>::max()) { 20000a3f0aSЗишан Мирза return nullptr; 21000a3f0aSЗишан Мирза } 22*f9c2377fSMichael Jones static char buffer[time_constants::ASCTIME_BUFFER_SIZE]; 23000a3f0aSЗишан Мирза return time_utils::asctime(time_utils::localtime(t_ptr), buffer, 24*f9c2377fSMichael Jones time_constants::ASCTIME_MAX_BYTES); 25000a3f0aSЗишан Мирза } 26000a3f0aSЗишан Мирза 27000a3f0aSЗишан Мирза } // namespace LIBC_NAMESPACE_DECL 28