From b524a4a66109d4545eab9a4204b2a1a7e6f9ed84 Mon Sep 17 00:00:00 2001 From: toh Date: Thu, 6 Mar 2025 11:54:59 +0100 Subject: [PATCH] Fix #3352 (Missing test for Apple / POSIX.1-2024 chooses buggy workaround) Apple platforms have had the tm_gmtoff-field at least since Mac OS X 10.0, as are POSIX.1-2024 conforming systems, which are also required to support it. This has the unfortunate effect to use the SunOS/Solaris fallback, which doesn't compute the correct value if the passed value of tm isn't the current system time, i.e. localtime(::time()) (#3351). --- include/spdlog/details/os-inl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index 8ee42304..a9f77d42 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -267,7 +267,8 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) { #if defined(sun) || defined(__sun) || defined(_AIX) || \ (defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || \ - (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE)) + (!defined(__APPLE__) && !defined(_BSD_SOURCE) && !defined(_GNU_SOURCE) && \ + (!defined(_POSIX_VERSION) || (_POSIX_VERSION < 202405L))) // 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris struct helper { static long int calculate_gmt_offset(const std::tm &localtm = details::os::localtime(),