don't. */
#undef HAVE_DECL_STRNLEN
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#undef HAVE_DECL_TZNAME
+
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#undef HAVE_STRUCT_DIRENT_D_TYPE
+/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+#undef HAVE_STRUCT_TM_TM_ZONE
+
/* Define if strxfrm_l is available in <string.h>. */
#undef HAVE_STRXFRM_L
/* Define to 1 if the target supports thread-local storage. */
#undef HAVE_TLS
+/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
+ `HAVE_STRUCT_TM_TM_ZONE' instead. */
+#undef HAVE_TM_ZONE
+
/* Define if truncate is available in <unistd.h>. */
#undef HAVE_TRUNCATE
+/* Define to 1 if you don't have `tm_zone' but do have the external array
+ `tzname'. */
+#undef HAVE_TZNAME
+
/* Define to 1 if you have the <uchar.h> header file. */
#undef HAVE_UCHAR_H
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
/* Version number of package */
#undef VERSION
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
+
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
+$as_echo_n "checking for $2.$3... " >&6; }
+if eval \${$4+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (ac_aggr.$3)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$4=yes"
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (sizeof ac_aggr.$3)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$4=yes"
+else
+ eval "$4=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$4
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_member
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12283 "configure"
+#line 12340 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12389 "configure"
+#line 12446 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 16185 "configure"
+#line 16242 "configure"
int main()
{
typedef bool atomic_type;
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16220 "configure"
+#line 16277 "configure"
int main()
{
typedef short atomic_type;
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16255 "configure"
+#line 16312 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16291 "configure"
+#line 16348 "configure"
int main()
{
typedef long long atomic_type;
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16447 "configure"
+#line 16504 "configure"
int main()
{
_Decimal32 d1;
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16489 "configure"
+#line 16546 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
+$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
+if ${ac_cv_struct_tm+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <time.h>
+
+int
+main ()
+{
+struct tm tm;
+ int *p = &tm.tm_sec;
+ return !p;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_struct_tm=time.h
+else
+ ac_cv_struct_tm=sys/time.h
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
+$as_echo "$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
+
+fi
+
+ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+
+"
+if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_TM_TM_ZONE 1
+_ACEOF
+
+
+fi
+
+if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
+
+$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h
+
+else
+ ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h>
+"
+if test "x$ac_cv_have_decl_tzname" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_TZNAME $ac_have_decl
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
+$as_echo_n "checking for tzname... " >&6; }
+if ${ac_cv_var_tzname+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <time.h>
+#if !HAVE_DECL_TZNAME
+extern char *tzname[];
+#endif
+
+int
+main ()
+{
+return tzname[0][0];
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_var_tzname=yes
+else
+ ac_cv_var_tzname=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5
+$as_echo "$ac_cv_var_tzname" >&6; }
+ if test $ac_cv_var_tzname = yes; then
+
+$as_echo "#define HAVE_TZNAME 1" >>confdefs.h
+
+ fi
+fi
+
+
# Define documentation rules conditionally.
# See if makeinfo has been installed and is modern enough
# For std::text_encoding
GLIBCXX_CHECK_TEXT_ENCODING
+AC_STRUCT_TIMEZONE
+
# Define documentation rules conditionally.
# See if makeinfo has been installed and is modern enough
// %Ec Locale's alternate date and time representation.
using namespace chrono;
+ using ::std::chrono::__detail::__utc_leap_second;
+ using ::std::chrono::__detail::__local_time_fmt;
+
+ struct tm __tm{};
+
+ // Some locales use %Z in their %c format but we don't want strftime
+ // to use the system's local time zone (from /etc/localtime or $TZ)
+ // as the output for %Z. Setting tm_isdst to -1 says there is no
+ // time zone info available for the time in __tm.
+ __tm.tm_isdst = -1;
+
+#ifdef _GLIBCXX_HAVE_STRUCT_TM_TM_ZONE
+ // POSIX.1-2024 adds tm.tm_zone which will be used for %Z.
+ if constexpr (__is_time_point_v<_Tp>)
+ {
+ // One of sys_time, utc_time, or local_time.
+ if constexpr (!is_same_v<typename _Tp::clock, local_t>)
+ __tm.tm_zone = "UTC";
+ }
+ else if constexpr (__is_specialization_of<_Tp, __local_time_fmt>)
+ {
+ // local-time-format-t is used to provide time zone info for
+ // one of zoned_time, tai_time, gps_time, or local_time.
+ if (__t._M_abbrev)
+ __tm.tm_zone = __t._M_abbrev->c_str();
+ }
+ else
+ __tm.tm_zone = "UTC";
+#endif
+
auto __d = _S_days(__t); // Either sys_days or local_days.
using _TDays = decltype(__d);
const year_month_day __ymd(__d);
const auto __y = __ymd.year();
const auto __hms = _S_hms(__t);
- struct tm __tm{};
__tm.tm_year = (int)__y - 1900;
__tm.tm_yday = (__d - _TDays(__y/January/1)).count();
__tm.tm_mon = (unsigned)__ymd.month() - 1;
__tm.tm_hour = __hms.hours().count();
__tm.tm_min = __hms.minutes().count();
__tm.tm_sec = __hms.seconds().count();
+
return _M_locale_fmt(std::move(__out), _M_locale(__ctx), __tm, 'c',
__mod ? 'E' : '\0');
}
}
}
+#include <stdlib.h>
+#include <time.h>
+
+extern "C++" int tzset(int);
+
+template<typename T = void>
+void maybe_set_tz()
+{
+#ifdef _GLIBCXX_HAVE_SETENV
+ // True if a function 'T tzset()' has been declared.
+ if constexpr (requires (T (*p)()) { p = &tzset; })
+ {
+ setenv("TZ", "GMT0", 1);
+ tzset(); // Set C library's global time zone to GMT0
+ }
+#endif
+}
+
+void
+test_c_zoned()
+{
+#if _GLIBCXX_USE_CXX11_ABI
+ maybe_set_tz();
+
+ using namespace std::chrono;
+ auto time = sys_days(2025y/March/19) + 15h;
+ zoned_time z("America/New_York", time);
+ auto s = std::format(std::locale("aa_DJ.UTF-8"), "{:L%c}", z);
+ VERIFY( s.find("11:00") != s.npos );
+
+ // We should not print an incorrect time zone.
+ VERIFY( s.find("GMT") == s.npos );
+ VERIFY( s.find("UTC") == s.npos );
+
+#ifdef _GLIBCXX_HAVE_STRUCT_TM_TM_ZONE
+ // When tm.tm_zone is supported, we do print the correct time zone.
+ VERIFY( s.find(z.get_info().abbrev) != s.npos );
+#endif
+#endif
+}
+
+void
+test_c_local()
+{
+ maybe_set_tz();
+
+ std::locale("aa_DJ.UTF-8");
+ using namespace std::chrono;
+ auto time = local_days(2025y/March/19) + 11h;
+ auto s = std::format(std::locale("aa_DJ.UTF-8"), "{:L%c}", time);
+ // __builtin_printf("%s\n", s.c_str()); return;
+ VERIFY( s.find("11:00") != s.npos );
+
+ // We should not print any time zone.
+ VERIFY( s.find("GMT") == s.npos );
+ VERIFY( s.find("UTC") == s.npos );
+
+#if _GLIBCXX_USE_CXX11_ABI
+ zoned_time z(system_clock::now());
+ VERIFY( s.find(z.get_info().abbrev) == s.npos );
+#endif
+}
+
int main()
{
test_c();
+ test_c_zoned();
+ test_c_local();
}