mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 11:17:35 +02:00
Enable tzset only on Windows desktop app (#2633)
This commit is contained in:
committed by
GitHub
parent
215f21a038
commit
9d5b9defde
@ -20,6 +20,20 @@
|
|||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
// Enable tzset.
|
||||||
|
#ifndef FMT_USE_TZSET
|
||||||
|
// UWP doesn't provide _tzset.
|
||||||
|
# if FMT_HAS_INCLUDE("winapifamily.h")
|
||||||
|
# include <winapifamily.h>
|
||||||
|
# endif
|
||||||
|
# if defined(_WIN32) && (!defined(WINAPI_FAMILY) || \
|
||||||
|
(WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
|
||||||
|
# define FMT_USE_TZSET 1
|
||||||
|
# else
|
||||||
|
# define FMT_USE_TZSET 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enable safe chrono durations, unless explicitly disabled.
|
// Enable safe chrono durations, unless explicitly disabled.
|
||||||
#ifndef FMT_SAFE_DURATION_CAST
|
#ifndef FMT_SAFE_DURATION_CAST
|
||||||
# define FMT_SAFE_DURATION_CAST 1
|
# define FMT_SAFE_DURATION_CAST 1
|
||||||
@ -924,7 +938,7 @@ template <typename T>
|
|||||||
struct has_member_data_tm_zone<T, void_t<decltype(T::tm_zone)>>
|
struct has_member_data_tm_zone<T, void_t<decltype(T::tm_zone)>>
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if FMT_USE_TZSET
|
||||||
inline void tzset_once() {
|
inline void tzset_once() {
|
||||||
static bool init = []() -> bool {
|
static bool init = []() -> bool {
|
||||||
_tzset();
|
_tzset();
|
||||||
@ -1067,7 +1081,9 @@ template <typename OutputIt, typename Char> class tm_writer {
|
|||||||
}
|
}
|
||||||
void format_utc_offset_impl(std::false_type) {
|
void format_utc_offset_impl(std::false_type) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
# if FMT_USE_TZSET
|
||||||
tzset_once();
|
tzset_once();
|
||||||
|
# endif
|
||||||
long offset = 0;
|
long offset = 0;
|
||||||
_get_timezone(&offset);
|
_get_timezone(&offset);
|
||||||
if (tm_.tm_isdst) {
|
if (tm_.tm_isdst) {
|
||||||
|
Reference in New Issue
Block a user