summaryrefslogtreecommitdiff
path: root/libc/src/time/time_utils.cpp
AgeCommit message (Collapse)Author
2025-03-25[libc][time] Fix -Wshorten-64-to-32 warning (#132947)Paul Kirth
This breaks builds of libc with top of tree clang under -Werror.
2025-03-25[libc] change the return value type of mktime_internal to time_t (#132231)Leslie
This pr is to resovle #126948 --------- Co-authored-by: Joseph Huber <huberjn@outlook.com>
2025-02-11[libc] create TimeReader to look at a struct tm (#126138)Michael Jones
In the process of adding strftime (#122556) I wrote this utility class to simplify reading from a struct tm. It provides helper functions that return basically everything needed by strftime. It's not tested directly, but it is thoroughly exercised by the strftime tests.
2025-01-08[libc][NFC] Cleanup time.h (#122027)Michael Jones
While working on strftime I noticed some constants were being defined in unexpected places. One thing led to another, and I ended up doing a major cleanup of the time functions. What's included: All uses of <time.h> in /src and /test removed (except for LibcTest.cpp) The various time constants have been moved to time_constants.h, and the `time_constants` namespace. struct tm gets its own type indirection header now.
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-01-24[libc] Add C23 limits.h header. (#78887)lntue
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-09-07[libc] Fix overflow check for 32 bit long time_t (#65394)Mikhail R. Gadelha
This patch fixes the overflow check in update_from_seconds, used by gmtime, gmtime_r and mktime. In update_from_seconds, total_seconds is a int64_t and the previous overflow check for when sizeof(time_t) == 4 would check if it was < 0x80000000 and > 0x7FFFFFFF, however, this check would cause the following issues: 1. Valid negative numbers would be discarded, e.g., -1 is 0xffffffffffffffff as a int64_t, outside the range of the overflow check. 2. Some valid positive numbers would be discarded because the hex constants were being implicitly converted to int64_t, e.g., 0x80000000 would be implicitly converted to 2147483648, instead of -2147483648. The fix for both cases was to static_cast total_seconds and the constants to time_t if sizeof(time_t) == 4. The behaviour is not changed in systems with sizeof(time_t) == 8. --------- Signed-off-by: Mikhail R. Gadelha <mikhail@igalia.com>
2023-08-07[libc][cleanup] Fix most conversion warningsMichael Jones
This patch is large, but is almost entirely just adding casts to calls to syscall_impl. Much of the work was done programatically, with human checking when the syntax or types got confusing. Reviewed By: mcgrathr Differential Revision: https://reviews.llvm.org/D156950
2023-04-28[libc][NFC] Start cleanup of time functionsMichael Jones
The time functions have not yet been updated to match our new coding patterns. This patch removes some unnecessary includes, adjusts the names of the test targets, and adds several TODO comments. It is my intention to follow this patch up with additional cleanup. Reviewed By: sivachandra, rtenneti Differential Revision: https://reviews.llvm.org/D149487
2021-12-07[libc] apply new lint rulesMichael Jones
This patch applies the lint rules described in the previous patch. There was also a significant amount of effort put into manually fixing things, since all of the templated functions, or structs defined in /spec, were not updated and had to be handled manually. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D114302
2021-03-16This introduces gmtime to LLVM libc, based on C99/C2X/Single Unix Spec.Raman Tenneti
This change doesn't handle TIMEZONE, tm_isdst and leap seconds. Moved shared code between mktime and gmtime into time_utils.cpp. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D98467