Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for win desktop app #2629

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ template <typename T>
struct has_member_data_tm_gmtoff<T, void_t<decltype(T::tm_gmtoff)>>
: std::true_type {};

#if defined(_WIN32)
#if defined(_WIN32) && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge tzset_once into format_utc_offset_impl to avoid repeating the check and since it's only used there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitaut, after the proposed merge the _tzset function will be called multiple times. Once for each tm_writer template instantiation.
It won't throw an error. But there may be a slowdown if present many tm_writer template instantiation with differents args.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's keep this function but introduce a macro FMT_USE_TZSET instead to avoid repetition.

inline void tzset_once() {
static bool init = []() -> bool {
_tzset();
Expand Down Expand Up @@ -1020,7 +1020,7 @@ template <typename OutputIt, typename Char> class tm_writer {
write_utc_offset(tm_.tm_gmtoff);
}
void format_utc_offset_impl(std::false_type) {
#if defined(_WIN32)
#if defined(_WIN32) && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
tzset_once();
long offset = 0;
_get_timezone(&offset);
Expand Down