diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc index 101e20c1bd9..992c203f8f6 100644 --- a/absl/time/internal/cctz/src/time_zone_info.cc +++ b/absl/time/internal/cctz/src/time_zone_info.cc @@ -434,11 +434,7 @@ std::unique_ptr FileZoneInfoSource::Open( // Map the time-zone name to a path name. std::string path; if (pos == name.size() || name[pos] != '/') { -#ifdef PRINCIPIA_TZDIR - const char* tzdir = PRINCIPIA_TZDIR; -#else const char* tzdir = "/usr/share/zoneinfo"; -#endif char* tzdir_env = nullptr; #if defined(_MSC_VER) _dupenv_s(&tzdir_env, nullptr, "TZDIR"); diff --git a/absl/time/internal/cctz/src/time_zone_libc.cc b/absl/time/internal/cctz/src/time_zone_libc.cc index 362da1ab58b..03c1c84088f 100644 --- a/absl/time/internal/cctz/src/time_zone_libc.cc +++ b/absl/time/internal/cctz/src/time_zone_libc.cc @@ -42,9 +42,10 @@ namespace { #if defined(_WIN32) || defined(_WIN64) // Uses the globals: '_timezone', '_dstbias' and '_tzname'. +// NOTE(phl): Microsoft, being in Redmond, counts West and not East. auto tm_gmtoff(const std::tm& tm) -> decltype(_timezone + _dstbias) { const bool is_dst = tm.tm_isdst > 0; - return _timezone + (is_dst ? _dstbias : 0); + return -(_timezone + (is_dst ? _dstbias : 0)); } auto tm_zone(const std::tm& tm) -> decltype(_tzname[0]) { const bool is_dst = tm.tm_isdst > 0; diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc index d1078de433e..475f1fe797f 100644 --- a/absl/time/internal/cctz/src/time_zone_lookup.cc +++ b/absl/time/internal/cctz/src/time_zone_lookup.cc @@ -165,10 +165,17 @@ time_zone local_time_zone() { } #endif #if defined(_WIN32) +// The time_zone_info.cc code is incapable of finding the time zones on Windows. +// (It looks in /usr/share/zoneinfo...) Since we only care about the local +// time, fall back to the libc implementation. +# ifdef PRINCIPIA + zone = "libc:localtime"; +# else std::string win32_tz = GetWindowsLocalTimeZone(); if (!win32_tz.empty()) { zone = win32_tz.c_str(); } +# endif #endif // Allow ${TZ} to override to default zone. diff --git a/msvc/abseil-cpp.props b/msvc/abseil-cpp.props index 4cd2d2e76b3..aa819b0b531 100644 --- a/msvc/abseil-cpp.props +++ b/msvc/abseil-cpp.props @@ -69,10 +69,7 @@ stdc17 stdcpplatest true - - PRINCIPIA; - PRINCIPIA_TZDIR=R"literal($(SolutionDir)\..\absl\time\internal\cctz\testdata\zoneinfo)literal" - + PRINCIPIA true true Level3