#if !defined(_CRT_SECURE_NO_WARNINGS) && defined(_WIN32)
#define _CRT_SECURE_NO_WARNINGS …
#endif
#include "time_zone_libc.h"
#include <chrono>
#include <ctime>
#include <limits>
#include <utility>
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
#if defined(_AIX)
extern "C" {
extern long altzone;
}
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace time_internal {
namespace cctz {
namespace {
#if defined(_WIN32) || defined(_WIN64)
auto tm_gmtoff(const std::tm& tm) -> decltype(_timezone + _dstbias) {
const bool is_dst = tm.tm_isdst > 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;
return _tzname[is_dst];
}
#elif defined(__sun) || defined(_AIX)
auto tm_gmtoff(const std::tm& tm) -> decltype(timezone) {
const bool is_dst = tm.tm_isdst > 0;
return is_dst ? altzone : timezone;
}
auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
const bool is_dst = tm.tm_isdst > 0;
return tzname[is_dst];
}
#elif defined(__native_client__) || defined(__myriad2__) || \
defined(__EMSCRIPTEN__)
auto tm_gmtoff(const std::tm& tm) -> decltype(_timezone + 0) {
const bool is_dst = tm.tm_isdst > 0;
return _timezone + (is_dst ? 60 * 60 : 0);
}
auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
const bool is_dst = tm.tm_isdst > 0;
return tzname[is_dst];
}
#elif defined(__VXWORKS__)
auto tm_gmtoff(const std::tm& tm) -> decltype(timezone + 0) {
const bool is_dst = tm.tm_isdst > 0;
return timezone + (is_dst ? 60 * 60 : 0);
}
auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
const bool is_dst = tm.tm_isdst > 0;
return tzname[is_dst];
}
#else
#if defined(tm_gmtoff)
auto tm_gmtoff(const std::tm& tm) -> decltype(tm.tm_gmtoff) {
return tm.tm_gmtoff;
}
#elif defined(__tm_gmtoff)
auto tm_gmtoff(const std::tm& tm) -> decltype(tm.__tm_gmtoff) {
return tm.__tm_gmtoff;
}
#else
template <typename T>
auto tm_gmtoff(const T& tm) -> decltype(tm.tm_gmtoff) { … }
template <typename T>
auto tm_gmtoff(const T& tm) -> decltype(tm.__tm_gmtoff) { … }
#endif
#if defined(tm_zone)
auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) { return tm.tm_zone; }
#elif defined(__tm_zone)
auto tm_zone(const std::tm& tm) -> decltype(tm.__tm_zone) {
return tm.__tm_zone;
}
#else
template <typename T>
auto tm_zone(const T& tm) -> decltype(tm.tm_zone) { … }
template <typename T>
auto tm_zone(const T& tm) -> decltype(tm.__tm_zone) { … }
#endif
#endif
tm_gmtoff_t;
inline std::tm* gm_time(const std::time_t* timep, std::tm* result) { … }
inline std::tm* local_time(const std::time_t* timep, std::tm* result) { … }
bool make_time(const civil_second& cs, int is_dst, std::time_t* t,
std::tm* tm) { … }
std::time_t find_trans(std::time_t lo, std::time_t hi, tm_gmtoff_t offset) { … }
}
std::unique_ptr<TimeZoneLibC> TimeZoneLibC::Make(const std::string& name) { … }
time_zone::absolute_lookup TimeZoneLibC::BreakTime(
const time_point<seconds>& tp) const { … }
time_zone::civil_lookup TimeZoneLibC::MakeTime(const civil_second& cs) const { … }
bool TimeZoneLibC::NextTransition(const time_point<seconds>&,
time_zone::civil_transition*) const { … }
bool TimeZoneLibC::PrevTransition(const time_point<seconds>&,
time_zone::civil_transition*) const { … }
std::string TimeZoneLibC::Version() const { … }
std::string TimeZoneLibC::Description() const { … }
TimeZoneLibC::TimeZoneLibC(const std::string& name)
: … { … }
}
}
ABSL_NAMESPACE_END
}