Export of internal Abseil changes
-- 20b3acaff75d05315f272747956b01405adccafb by Greg Falcon <gfalcon@google.com>: Re-import of CCTZ from GitHub, with new ABSL_NAMESPACE_ transform applied. PiperOrigin-RevId: 285564474 -- 4d9e3fcabcea33c8b0b69f094ad2eddc0fa19557 by Derek Mauro <dmauro@google.com>: Moves the disabling of a warning to before the function begins. MSVC apparently requires this for warnings in the range 4700-4999. https://docs.microsoft.com/en-us/cpp/preprocessor/warning?redirectedfrom=MSDN&view=vs-2019 PiperOrigin-RevId: 285516232 -- 4a060cbeda76e89693c50276ae5b62cbf0fff39a by Derek Mauro <dmauro@google.com>: MSVC: Fixes uniform_real_distribution_test in opt mode Disables a constant arithmetic overflow warning in a test that tests the behavior on overflow. This should be tested because a user might have this warning disabled. PiperOrigin-RevId: 285452242 -- 548ab2f4cbe59bd6f6bf493af4f9ea765c4fa949 by Andy Soffer <asoffer@google.com>: Release absl::bind_front, a C++11-compliant work-alike type for the C++20 std::bind_front. PiperOrigin-RevId: 285247872 GitOrigin-RevId: 20b3acaff75d05315f272747956b01405adccafb Change-Id: I00fe45939246cba9bfc7be375d67787d2eb57cd3
This commit is contained in:
parent
12bc53e031
commit
bf86cfe165
31 changed files with 1972 additions and 1421 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -18,7 +18,10 @@
|
|||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
namespace detail {
|
||||
|
|
@ -87,4 +90,5 @@ std::ostream& operator<<(std::ostream& os, weekday wd) {
|
|||
} // namespace detail
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@
|
|||
#include <type_traits>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -1014,19 +1016,13 @@ TEST(CivilTime, LeapYears) {
|
|||
int day;
|
||||
} leap_day; // The date of the day after Feb 28.
|
||||
} kLeapYearTable[]{
|
||||
{1900, 365, {3, 1}},
|
||||
{1999, 365, {3, 1}},
|
||||
{1900, 365, {3, 1}}, {1999, 365, {3, 1}},
|
||||
{2000, 366, {2, 29}}, // leap year
|
||||
{2001, 365, {3, 1}},
|
||||
{2002, 365, {3, 1}},
|
||||
{2003, 365, {3, 1}},
|
||||
{2004, 366, {2, 29}}, // leap year
|
||||
{2005, 365, {3, 1}},
|
||||
{2006, 365, {3, 1}},
|
||||
{2007, 365, {3, 1}},
|
||||
{2008, 366, {2, 29}}, // leap year
|
||||
{2009, 365, {3, 1}},
|
||||
{2100, 365, {3, 1}},
|
||||
{2001, 365, {3, 1}}, {2002, 365, {3, 1}},
|
||||
{2003, 365, {3, 1}}, {2004, 366, {2, 29}}, // leap year
|
||||
{2005, 365, {3, 1}}, {2006, 365, {3, 1}},
|
||||
{2007, 365, {3, 1}}, {2008, 366, {2, 29}}, // leap year
|
||||
{2009, 365, {3, 1}}, {2100, 365, {3, 1}},
|
||||
};
|
||||
|
||||
for (const auto& e : kLeapYearTable) {
|
||||
|
|
@ -1056,4 +1052,5 @@ TEST(CivilTime, FirstThursdayInMonth) {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -59,11 +62,9 @@ bool FixedOffsetFromName(const std::string& name, seconds* offset) {
|
|||
const char* const ep = kFixedZonePrefix + prefix_len;
|
||||
if (name.size() != prefix_len + 9) // <prefix>+99:99:99
|
||||
return false;
|
||||
if (!std::equal(kFixedZonePrefix, ep, name.begin()))
|
||||
return false;
|
||||
if (!std::equal(kFixedZonePrefix, ep, name.begin())) return false;
|
||||
const char* np = name.data() + prefix_len;
|
||||
if (np[0] != '+' && np[0] != '-')
|
||||
return false;
|
||||
if (np[0] != '+' && np[0] != '-') return false;
|
||||
if (np[3] != ':' || np[6] != ':') // see note below about large offsets
|
||||
return false;
|
||||
|
||||
|
|
@ -135,4 +136,5 @@ std::string FixedOffsetToAbbr(const seconds& offset) {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -44,6 +46,7 @@ std::string FixedOffsetToAbbr(const seconds& offset);
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_FIXED_H_
|
||||
|
|
|
|||
|
|
@ -13,17 +13,18 @@
|
|||
// limitations under the License.
|
||||
|
||||
#if !defined(HAS_STRPTIME)
|
||||
# if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
# define HAS_STRPTIME 1 // assume everyone has strptime() except windows
|
||||
# endif
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
#define HAS_STRPTIME 1 // assume everyone has strptime() except windows
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAS_STRPTIME) && HAS_STRPTIME
|
||||
# if !defined(_XOPEN_SOURCE)
|
||||
# define _XOPEN_SOURCE // Definedness suffices for strptime.
|
||||
# endif
|
||||
#if !defined(_XOPEN_SOURCE)
|
||||
#define _XOPEN_SOURCE // Definedness suffices for strptime.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
|
||||
|
||||
// Include time.h directly since, by C++ standards, ctime doesn't have to
|
||||
|
|
@ -48,6 +49,7 @@
|
|||
#include "time_zone_if.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
namespace detail {
|
||||
|
|
@ -502,8 +504,9 @@ std::string format(const std::string& format, const time_point<seconds>& tp,
|
|||
bp = ep;
|
||||
if (n > 0) {
|
||||
if (n > kDigits10_64) n = kDigits10_64;
|
||||
bp = Format64(bp, n, (n > 15) ? fs.count() * kExp10[n - 15]
|
||||
: fs.count() / kExp10[15 - n]);
|
||||
bp = Format64(bp, n,
|
||||
(n > 15) ? fs.count() * kExp10[n - 15]
|
||||
: fs.count() / kExp10[15 - n]);
|
||||
if (*np == 'S') *--bp = '.';
|
||||
}
|
||||
if (*np == 'S') bp = Format02d(bp, al.cs.second());
|
||||
|
|
@ -720,10 +723,9 @@ bool parse(const std::string& format, const std::string& input,
|
|||
data = ParseZone(data, &zone);
|
||||
continue;
|
||||
case 's':
|
||||
data = ParseInt(data, 0,
|
||||
std::numeric_limits<std::int_fast64_t>::min(),
|
||||
std::numeric_limits<std::int_fast64_t>::max(),
|
||||
&percent_s);
|
||||
data =
|
||||
ParseInt(data, 0, std::numeric_limits<std::int_fast64_t>::min(),
|
||||
std::numeric_limits<std::int_fast64_t>::max(), &percent_s);
|
||||
if (data != nullptr) saw_percent_s = true;
|
||||
continue;
|
||||
case ':':
|
||||
|
|
@ -916,4 +918,5 @@ bool parse(const std::string& format, const std::string& input,
|
|||
} // namespace detail
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -12,20 +12,21 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#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"
|
||||
|
||||
namespace chrono = std::chrono;
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -48,10 +49,10 @@ namespace {
|
|||
} while (0)
|
||||
|
||||
const char RFC3339_full[] = "%Y-%m-%dT%H:%M:%E*S%Ez";
|
||||
const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez";
|
||||
const char RFC3339_sec[] = "%Y-%m-%dT%H:%M:%S%Ez";
|
||||
|
||||
const char RFC1123_full[] = "%a, %d %b %Y %H:%M:%S %z";
|
||||
const char RFC1123_no_wday[] = "%d %b %Y %H:%M:%S %z";
|
||||
const char RFC1123_no_wday[] = "%d %b %Y %H:%M:%S %z";
|
||||
|
||||
// A helper that tests the given format specifier by itself, and with leading
|
||||
// and trailing characters. For example: TestFormatSpecifier(tp, "%a", "Thu").
|
||||
|
|
@ -88,8 +89,11 @@ TEST(Format, TimePointResolution) {
|
|||
format(kFmt, chrono::time_point_cast<chrono::milliseconds>(t0), utc));
|
||||
EXPECT_EQ("03:04:05",
|
||||
format(kFmt, chrono::time_point_cast<chrono::seconds>(t0), utc));
|
||||
EXPECT_EQ("03:04:05",
|
||||
format(kFmt, chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), utc));
|
||||
EXPECT_EQ(
|
||||
"03:04:05",
|
||||
format(kFmt,
|
||||
chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0),
|
||||
utc));
|
||||
EXPECT_EQ("03:04:00",
|
||||
format(kFmt, chrono::time_point_cast<chrono::minutes>(t0), utc));
|
||||
EXPECT_EQ("03:00:00",
|
||||
|
|
@ -110,12 +114,10 @@ TEST(Format, TimePointExtendedResolution) {
|
|||
EXPECT_EQ(
|
||||
"12:34:56.012345678901234",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(12345678901234), utc));
|
||||
EXPECT_EQ(
|
||||
"12:34:56.001234567890123",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(1234567890123), utc));
|
||||
EXPECT_EQ(
|
||||
"12:34:56.000123456789012",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(123456789012), utc));
|
||||
EXPECT_EQ("12:34:56.001234567890123",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(1234567890123), utc));
|
||||
EXPECT_EQ("12:34:56.000123456789012",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(123456789012), utc));
|
||||
|
||||
EXPECT_EQ("12:34:56.000000000000123",
|
||||
detail::format(kFmt, tp, detail::femtoseconds(123), utc));
|
||||
|
|
@ -1416,8 +1418,8 @@ TEST(Parse, MaxRange) {
|
|||
parse(RFC3339_sec, "-292277022657-01-27T08:29:51+01:00", utc, &tp));
|
||||
|
||||
// tests max/min civil-second overflow
|
||||
EXPECT_FALSE(parse(RFC3339_sec, "9223372036854775807-12-31T23:59:59-00:01",
|
||||
utc, &tp));
|
||||
EXPECT_FALSE(
|
||||
parse(RFC3339_sec, "9223372036854775807-12-31T23:59:59-00:01", utc, &tp));
|
||||
EXPECT_FALSE(parse(RFC3339_sec, "-9223372036854775808-01-01T00:00:00+00:01",
|
||||
utc, &tp));
|
||||
|
||||
|
|
@ -1474,7 +1476,8 @@ TEST(FormatParse, RoundTrip) {
|
|||
|
||||
TEST(FormatParse, RoundTripDistantFuture) {
|
||||
const time_zone utc = utc_time_zone();
|
||||
const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::max();
|
||||
const time_point<absl::time_internal::cctz::seconds> in =
|
||||
time_point<absl::time_internal::cctz::seconds>::max();
|
||||
const std::string s = format(RFC3339_full, in, utc);
|
||||
time_point<absl::time_internal::cctz::seconds> out;
|
||||
EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s;
|
||||
|
|
@ -1483,7 +1486,8 @@ TEST(FormatParse, RoundTripDistantFuture) {
|
|||
|
||||
TEST(FormatParse, RoundTripDistantPast) {
|
||||
const time_zone utc = utc_time_zone();
|
||||
const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::min();
|
||||
const time_point<absl::time_internal::cctz::seconds> in =
|
||||
time_point<absl::time_internal::cctz::seconds>::min();
|
||||
const std::string s = format(RFC3339_full, in, utc);
|
||||
time_point<absl::time_internal::cctz::seconds> out;
|
||||
EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s;
|
||||
|
|
@ -1492,4 +1496,5 @@ TEST(FormatParse, RoundTripDistantPast) {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -13,10 +13,13 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "time_zone_if.h"
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "time_zone_info.h"
|
||||
#include "time_zone_libc.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -38,4 +41,5 @@ TimeZoneIf::~TimeZoneIf() {}
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -38,8 +40,7 @@ class TimeZoneIf {
|
|||
|
||||
virtual time_zone::absolute_lookup BreakTime(
|
||||
const time_point<seconds>& tp) const = 0;
|
||||
virtual time_zone::civil_lookup MakeTime(
|
||||
const civil_second& cs) const = 0;
|
||||
virtual time_zone::civil_lookup MakeTime(const civil_second& cs) const = 0;
|
||||
|
||||
virtual bool NextTransition(const time_point<seconds>& tp,
|
||||
time_zone::civil_transition* trans) const = 0;
|
||||
|
|
@ -58,15 +59,18 @@ class TimeZoneIf {
|
|||
// Unix clock are second aligned, but not that they share an epoch.
|
||||
inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) {
|
||||
return (tp - std::chrono::time_point_cast<seconds>(
|
||||
std::chrono::system_clock::from_time_t(0))).count();
|
||||
std::chrono::system_clock::from_time_t(0)))
|
||||
.count();
|
||||
}
|
||||
inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) {
|
||||
return std::chrono::time_point_cast<seconds>(
|
||||
std::chrono::system_clock::from_time_t(0)) + seconds(t);
|
||||
std::chrono::system_clock::from_time_t(0)) +
|
||||
seconds(t);
|
||||
}
|
||||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IF_H_
|
||||
|
|
|
|||
|
|
@ -20,9 +20,11 @@
|
|||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "time_zone_fixed.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -43,9 +45,7 @@ std::mutex& TimeZoneMutex() {
|
|||
|
||||
} // namespace
|
||||
|
||||
time_zone time_zone::Impl::UTC() {
|
||||
return time_zone(UTCImpl());
|
||||
}
|
||||
time_zone time_zone::Impl::UTC() { return time_zone(UTCImpl()); }
|
||||
|
||||
bool time_zone::Impl::LoadTimeZone(const std::string& name, time_zone* tz) {
|
||||
const time_zone::Impl* const utc_impl = UTCImpl();
|
||||
|
|
@ -117,4 +117,5 @@ const time_zone::Impl* time_zone::Impl::UTCImpl() {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
#include "time_zone_if.h"
|
||||
#include "time_zone_info.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -85,6 +87,7 @@ class time_zone::Impl {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_IMPL_H_
|
||||
|
|
|
|||
|
|
@ -45,11 +45,13 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
|
||||
#include "time_zone_fixed.h"
|
||||
#include "time_zone_posix.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -65,8 +67,8 @@ const std::int_least32_t kDaysPerYear[2] = {365, 366};
|
|||
// The day offsets of the beginning of each (1-based) month in non-leap and
|
||||
// leap years respectively (e.g., 335 days before December in a leap year).
|
||||
const std::int_least16_t kMonthOffsets[2][1 + 12 + 1] = {
|
||||
{-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
|
||||
{-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366},
|
||||
{-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
|
||||
{-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366},
|
||||
};
|
||||
|
||||
// We reject leap-second encoded zoneinfo and so assume 60-second minutes.
|
||||
|
|
@ -77,8 +79,8 @@ const std::int_least64_t kSecsPer400Years = 146097LL * kSecsPerDay;
|
|||
|
||||
// Like kDaysPerYear[] but scaled up by a factor of kSecsPerDay.
|
||||
const std::int_least32_t kSecsPerYear[2] = {
|
||||
365 * kSecsPerDay,
|
||||
366 * kSecsPerDay,
|
||||
365 * kSecsPerDay,
|
||||
366 * kSecsPerDay,
|
||||
};
|
||||
|
||||
// Single-byte, unsigned numeric values are encoded directly.
|
||||
|
|
@ -172,8 +174,8 @@ inline time_zone::civil_lookup MakeRepeated(const Transition& tr,
|
|||
}
|
||||
|
||||
inline civil_second YearShift(const civil_second& cs, year_t shift) {
|
||||
return civil_second(cs.year() + shift, cs.month(), cs.day(),
|
||||
cs.hour(), cs.minute(), cs.second());
|
||||
return civil_second(cs.year() + shift, cs.month(), cs.day(), cs.hour(),
|
||||
cs.minute(), cs.second());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
@ -216,7 +218,7 @@ bool TimeZoneInfo::ResetToBuiltinUTC(const seconds& offset) {
|
|||
default_transition_type_ = 0;
|
||||
abbreviations_ = FixedOffsetToAbbr(offset);
|
||||
abbreviations_.append(1, '\0'); // add NUL
|
||||
future_spec_.clear(); // never needed for a fixed-offset zone
|
||||
future_spec_.clear(); // never needed for a fixed-offset zone
|
||||
extended_ = false;
|
||||
|
||||
tt.civil_max = LocalTime(seconds::max().count(), tt).cs;
|
||||
|
|
@ -393,31 +395,24 @@ void TimeZoneInfo::ExtendTransitions(const std::string& name,
|
|||
bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
||||
// Read and validate the header.
|
||||
tzhead tzh;
|
||||
if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh))
|
||||
return false;
|
||||
if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false;
|
||||
if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0)
|
||||
return false;
|
||||
Header hdr;
|
||||
if (!hdr.Build(tzh))
|
||||
return false;
|
||||
if (!hdr.Build(tzh)) return false;
|
||||
std::size_t time_len = 4;
|
||||
if (tzh.tzh_version[0] != '\0') {
|
||||
// Skip the 4-byte data.
|
||||
if (zip->Skip(hdr.DataLength(time_len)) != 0)
|
||||
return false;
|
||||
if (zip->Skip(hdr.DataLength(time_len)) != 0) return false;
|
||||
// Read and validate the header for the 8-byte data.
|
||||
if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh))
|
||||
return false;
|
||||
if (zip->Read(&tzh, sizeof(tzh)) != sizeof(tzh)) return false;
|
||||
if (strncmp(tzh.tzh_magic, TZ_MAGIC, sizeof(tzh.tzh_magic)) != 0)
|
||||
return false;
|
||||
if (tzh.tzh_version[0] == '\0')
|
||||
return false;
|
||||
if (!hdr.Build(tzh))
|
||||
return false;
|
||||
if (tzh.tzh_version[0] == '\0') return false;
|
||||
if (!hdr.Build(tzh)) return false;
|
||||
time_len = 8;
|
||||
}
|
||||
if (hdr.typecnt == 0)
|
||||
return false;
|
||||
if (hdr.typecnt == 0) return false;
|
||||
if (hdr.leapcnt != 0) {
|
||||
// This code assumes 60-second minutes so we do not want
|
||||
// the leap-second encoded zoneinfo. We could reverse the
|
||||
|
|
@ -425,16 +420,13 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
|||
// so currently we simply reject such data.
|
||||
return false;
|
||||
}
|
||||
if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt)
|
||||
return false;
|
||||
if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt)
|
||||
return false;
|
||||
if (hdr.ttisstdcnt != 0 && hdr.ttisstdcnt != hdr.typecnt) return false;
|
||||
if (hdr.ttisutcnt != 0 && hdr.ttisutcnt != hdr.typecnt) return false;
|
||||
|
||||
// Read the data into a local buffer.
|
||||
std::size_t len = hdr.DataLength(time_len);
|
||||
std::vector<char> tbuf(len);
|
||||
if (zip->Read(tbuf.data(), len) != len)
|
||||
return false;
|
||||
if (zip->Read(tbuf.data(), len) != len) return false;
|
||||
const char* bp = tbuf.data();
|
||||
|
||||
// Decode and validate the transitions.
|
||||
|
|
@ -452,10 +444,8 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
|||
bool seen_type_0 = false;
|
||||
for (std::size_t i = 0; i != hdr.timecnt; ++i) {
|
||||
transitions_[i].type_index = Decode8(bp++);
|
||||
if (transitions_[i].type_index >= hdr.typecnt)
|
||||
return false;
|
||||
if (transitions_[i].type_index == 0)
|
||||
seen_type_0 = true;
|
||||
if (transitions_[i].type_index >= hdr.typecnt) return false;
|
||||
if (transitions_[i].type_index == 0) seen_type_0 = true;
|
||||
}
|
||||
|
||||
// Decode and validate the transition types.
|
||||
|
|
@ -469,8 +459,7 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
|||
bp += 4;
|
||||
transition_types_[i].is_dst = (Decode8(bp++) != 0);
|
||||
transition_types_[i].abbr_index = Decode8(bp++);
|
||||
if (transition_types_[i].abbr_index >= hdr.charcnt)
|
||||
return false;
|
||||
if (transition_types_[i].abbr_index >= hdr.charcnt) return false;
|
||||
}
|
||||
|
||||
// Determine the before-first-transition type.
|
||||
|
|
@ -479,13 +468,10 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
|||
std::uint_fast8_t index = 0;
|
||||
if (transition_types_[0].is_dst) {
|
||||
index = transitions_[0].type_index;
|
||||
while (index != 0 && transition_types_[index].is_dst)
|
||||
--index;
|
||||
while (index != 0 && transition_types_[index].is_dst) --index;
|
||||
}
|
||||
while (index != hdr.typecnt && transition_types_[index].is_dst)
|
||||
++index;
|
||||
if (index != hdr.typecnt)
|
||||
default_transition_type_ = index;
|
||||
while (index != hdr.typecnt && transition_types_[index].is_dst) ++index;
|
||||
if (index != hdr.typecnt) default_transition_type_ = index;
|
||||
}
|
||||
|
||||
// Copy all the abbreviations.
|
||||
|
|
@ -509,11 +495,9 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
|
|||
unsigned char ch; // all non-EOF results are positive
|
||||
return (azip->Read(&ch, 1) == 1) ? ch : EOF;
|
||||
};
|
||||
if (get_char(zip) != '\n')
|
||||
return false;
|
||||
if (get_char(zip) != '\n') return false;
|
||||
for (int c = get_char(zip); c != '\n'; c = get_char(zip)) {
|
||||
if (c == EOF)
|
||||
return false;
|
||||
if (c == EOF) return false;
|
||||
future_spec_.push_back(static_cast<char>(c));
|
||||
}
|
||||
}
|
||||
|
|
@ -624,7 +608,7 @@ class FileZoneInfoSource : public ZoneInfoSource {
|
|||
: fp_(fp, fclose), len_(len) {}
|
||||
|
||||
private:
|
||||
std::unique_ptr<FILE, int(*)(FILE*)> fp_;
|
||||
std::unique_ptr<FILE, int (*)(FILE*)> fp_;
|
||||
std::size_t len_;
|
||||
};
|
||||
|
||||
|
|
@ -748,13 +732,13 @@ time_zone::absolute_lookup TimeZoneInfo::LocalTime(
|
|||
// A civil time in "+offset" looks like (time+offset) in UTC.
|
||||
// Note: We perform two additions in the civil_second domain to
|
||||
// sidestep the chance of overflow in (unix_time + tt.utc_offset).
|
||||
return {(civil_second() + unix_time) + tt.utc_offset,
|
||||
tt.utc_offset, tt.is_dst, &abbreviations_[tt.abbr_index]};
|
||||
return {(civil_second() + unix_time) + tt.utc_offset, tt.utc_offset,
|
||||
tt.is_dst, &abbreviations_[tt.abbr_index]};
|
||||
}
|
||||
|
||||
// BreakTime() translation for a particular transition.
|
||||
time_zone::absolute_lookup TimeZoneInfo::LocalTime(
|
||||
std::int_fast64_t unix_time, const Transition& tr) const {
|
||||
time_zone::absolute_lookup TimeZoneInfo::LocalTime(std::int_fast64_t unix_time,
|
||||
const Transition& tr) const {
|
||||
const TransitionType& tt = transition_types_[tr.type_index];
|
||||
// Note: (unix_time - tr.unix_time) will never overflow as we
|
||||
// have ensured that there is always a "nearby" transition.
|
||||
|
|
@ -897,9 +881,7 @@ time_zone::civil_lookup TimeZoneInfo::MakeTime(const civil_second& cs) const {
|
|||
return MakeUnique(tr->unix_time + (cs - tr->civil_sec));
|
||||
}
|
||||
|
||||
std::string TimeZoneInfo::Version() const {
|
||||
return version_;
|
||||
}
|
||||
std::string TimeZoneInfo::Version() const { return version_; }
|
||||
|
||||
std::string TimeZoneInfo::Description() const {
|
||||
std::ostringstream oss;
|
||||
|
|
@ -921,8 +903,8 @@ bool TimeZoneInfo::NextTransition(const time_point<seconds>& tp,
|
|||
}
|
||||
std::int_fast64_t unix_time = ToUnixSeconds(tp);
|
||||
const Transition target = {unix_time, 0, civil_second(), civil_second()};
|
||||
const Transition* tr = std::upper_bound(begin, end, target,
|
||||
Transition::ByUnixTime());
|
||||
const Transition* tr =
|
||||
std::upper_bound(begin, end, target, Transition::ByUnixTime());
|
||||
for (; tr != end; ++tr) { // skip no-op transitions
|
||||
std::uint_fast8_t prev_type_index =
|
||||
(tr == begin) ? default_transition_type_ : tr[-1].type_index;
|
||||
|
|
@ -956,8 +938,8 @@ bool TimeZoneInfo::PrevTransition(const time_point<seconds>& tp,
|
|||
unix_time += 1; // ceils
|
||||
}
|
||||
const Transition target = {unix_time, 0, civil_second(), civil_second()};
|
||||
const Transition* tr = std::lower_bound(begin, end, target,
|
||||
Transition::ByUnixTime());
|
||||
const Transition* tr =
|
||||
std::lower_bound(begin, end, target, Transition::ByUnixTime());
|
||||
for (; tr != begin; --tr) { // skip no-op transitions
|
||||
std::uint_fast8_t prev_type_index =
|
||||
(tr - 1 == begin) ? default_transition_type_ : tr[-2].type_index;
|
||||
|
|
@ -972,4 +954,5 @@ bool TimeZoneInfo::PrevTransition(const time_point<seconds>& tp,
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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"
|
||||
#include "absl/time/internal/cctz/include/cctz/zone_info_source.h"
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
#include "tzfile.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -72,8 +74,7 @@ class TimeZoneInfo : public TimeZoneIf {
|
|||
// TimeZoneIf implementations.
|
||||
time_zone::absolute_lookup BreakTime(
|
||||
const time_point<seconds>& tp) const override;
|
||||
time_zone::civil_lookup MakeTime(
|
||||
const civil_second& cs) const override;
|
||||
time_zone::civil_lookup MakeTime(const civil_second& cs) const override;
|
||||
bool NextTransition(const time_point<seconds>& tp,
|
||||
time_zone::civil_transition* trans) const override;
|
||||
bool PrevTransition(const time_point<seconds>& tp,
|
||||
|
|
@ -82,7 +83,7 @@ class TimeZoneInfo : public TimeZoneIf {
|
|||
std::string Description() const override;
|
||||
|
||||
private:
|
||||
struct Header { // counts of:
|
||||
struct Header { // counts of:
|
||||
std::size_t timecnt; // transition times
|
||||
std::size_t typecnt; // transition types
|
||||
std::size_t charcnt; // zone abbreviation characters
|
||||
|
|
@ -114,7 +115,7 @@ class TimeZoneInfo : public TimeZoneIf {
|
|||
|
||||
std::vector<Transition> transitions_; // ordered by unix_time and civil_sec
|
||||
std::vector<TransitionType> transition_types_; // distinct transition types
|
||||
std::uint_fast8_t default_transition_type_; // for before first transition
|
||||
std::uint_fast8_t default_transition_type_; // for before first transition
|
||||
std::string abbreviations_; // all the NUL-terminated abbreviations
|
||||
|
||||
std::string version_; // the tzdata version if available
|
||||
|
|
@ -131,6 +132,7 @@ class TimeZoneInfo : public TimeZoneIf {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_INFO_H_
|
||||
|
|
|
|||
|
|
@ -23,10 +23,12 @@
|
|||
#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"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -84,9 +86,7 @@ auto tm_gmtoff(const T& tm) -> decltype(tm.__tm_gmtoff) {
|
|||
}
|
||||
#endif // tm_gmtoff
|
||||
#if defined(tm_zone)
|
||||
auto tm_zone(const std::tm& tm) -> decltype(tm.tm_zone) {
|
||||
return tm.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;
|
||||
|
|
@ -103,19 +103,19 @@ auto tm_zone(const T& tm) -> decltype(tm.__tm_zone) {
|
|||
#endif // tm_zone
|
||||
#endif
|
||||
|
||||
inline std::tm* gm_time(const std::time_t *timep, std::tm *result) {
|
||||
inline std::tm* gm_time(const std::time_t* timep, std::tm* result) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return gmtime_s(result, timep) ? nullptr : result;
|
||||
return gmtime_s(result, timep) ? nullptr : result;
|
||||
#else
|
||||
return gmtime_r(timep, result);
|
||||
return gmtime_r(timep, result);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::tm* local_time(const std::time_t *timep, std::tm *result) {
|
||||
inline std::tm* local_time(const std::time_t* timep, std::tm* result) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return localtime_s(result, timep) ? nullptr : result;
|
||||
return localtime_s(result, timep) ? nullptr : result;
|
||||
#else
|
||||
return localtime_r(timep, result);
|
||||
return localtime_r(timep, result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -208,8 +208,8 @@ time_zone::absolute_lookup TimeZoneLibC::BreakTime(
|
|||
}
|
||||
|
||||
const year_t year = tmp->tm_year + year_t{1900};
|
||||
al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday,
|
||||
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||
al.cs = civil_second(year, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour,
|
||||
tmp->tm_min, tmp->tm_sec);
|
||||
al.offset = static_cast<int>(tm_gmtoff(*tmp));
|
||||
al.abbr = local_ ? tm_zone(*tmp) : "UTC"; // as expected by cctz
|
||||
al.is_dst = tmp->tm_isdst > 0;
|
||||
|
|
@ -304,4 +304,5 @@ std::string TimeZoneLibC::Description() const {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "time_zone_if.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -33,8 +35,7 @@ class TimeZoneLibC : public TimeZoneIf {
|
|||
// TimeZoneIf implementations.
|
||||
time_zone::absolute_lookup BreakTime(
|
||||
const time_point<seconds>& tp) const override;
|
||||
time_zone::civil_lookup MakeTime(
|
||||
const civil_second& cs) const override;
|
||||
time_zone::civil_lookup MakeTime(const civil_second& cs) const override;
|
||||
bool NextTransition(const time_point<seconds>& tp,
|
||||
time_zone::civil_transition* trans) const override;
|
||||
bool PrevTransition(const time_point<seconds>& tp,
|
||||
|
|
@ -48,6 +49,7 @@ class TimeZoneLibC : public TimeZoneIf {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_LIBC_H_
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
|
||||
#if defined(__APPLE__)
|
||||
#include <CoreFoundation/CFTimeZone.h>
|
||||
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
|
|
@ -34,6 +36,7 @@
|
|||
#include "time_zone_impl.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -66,9 +69,7 @@ int __system_property_get(const char* name, char* value) {
|
|||
} // namespace
|
||||
#endif
|
||||
|
||||
std::string time_zone::name() const {
|
||||
return effective_impl().Name();
|
||||
}
|
||||
std::string time_zone::name() const { return effective_impl().Name(); }
|
||||
|
||||
time_zone::absolute_lookup time_zone::lookup(
|
||||
const time_point<seconds>& tp) const {
|
||||
|
|
@ -89,9 +90,7 @@ bool time_zone::prev_transition(const time_point<seconds>& tp,
|
|||
return effective_impl().PrevTransition(tp, trans);
|
||||
}
|
||||
|
||||
std::string time_zone::version() const {
|
||||
return effective_impl().Version();
|
||||
}
|
||||
std::string time_zone::version() const { return effective_impl().Version(); }
|
||||
|
||||
std::string time_zone::description() const {
|
||||
return effective_impl().Description();
|
||||
|
|
@ -184,4 +183,5 @@ time_zone local_time_zone() {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,10 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -152,4 +155,5 @@ bool ParsePosixSpec(const std::string& spec, PosixTimeZone* res) {
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
|
|
@ -55,7 +55,10 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -123,6 +126,7 @@ bool ParsePosixSpec(const std::string& spec, PosixTimeZone* res);
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_TIME_INTERNAL_CCTZ_TIME_ZONE_POSIX_H_
|
||||
|
|
|
|||
|
|
@ -22,36 +22,35 @@
|
|||
*/
|
||||
|
||||
#ifndef TZDIR
|
||||
#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
|
||||
#endif /* !defined TZDIR */
|
||||
#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
|
||||
#endif /* !defined TZDIR */
|
||||
|
||||
#ifndef TZDEFAULT
|
||||
#define TZDEFAULT "/etc/localtime"
|
||||
#define TZDEFAULT "/etc/localtime"
|
||||
#endif /* !defined TZDEFAULT */
|
||||
|
||||
#ifndef TZDEFRULES
|
||||
#define TZDEFRULES "posixrules"
|
||||
#define TZDEFRULES "posixrules"
|
||||
#endif /* !defined TZDEFRULES */
|
||||
|
||||
|
||||
/* See Internet RFC 8536 for more details about the following format. */
|
||||
|
||||
/*
|
||||
** Each file begins with. . .
|
||||
*/
|
||||
|
||||
#define TZ_MAGIC "TZif"
|
||||
#define TZ_MAGIC "TZif"
|
||||
|
||||
struct tzhead {
|
||||
char tzh_magic[4]; /* TZ_MAGIC */
|
||||
char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */
|
||||
char tzh_reserved[15]; /* reserved; must be zero */
|
||||
char tzh_ttisutcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_leapcnt[4]; /* coded number of leap seconds */
|
||||
char tzh_timecnt[4]; /* coded number of transition times */
|
||||
char tzh_typecnt[4]; /* coded number of local time types */
|
||||
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
||||
char tzh_magic[4]; /* TZ_MAGIC */
|
||||
char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */
|
||||
char tzh_reserved[15]; /* reserved; must be zero */
|
||||
char tzh_ttisutcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_leapcnt[4]; /* coded number of leap seconds */
|
||||
char tzh_timecnt[4]; /* coded number of transition times */
|
||||
char tzh_typecnt[4]; /* coded number of local time types */
|
||||
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -103,21 +102,21 @@ struct tzhead {
|
|||
*/
|
||||
|
||||
#ifndef TZ_MAX_TIMES
|
||||
#define TZ_MAX_TIMES 2000
|
||||
#define TZ_MAX_TIMES 2000
|
||||
#endif /* !defined TZ_MAX_TIMES */
|
||||
|
||||
#ifndef TZ_MAX_TYPES
|
||||
/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */
|
||||
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
||||
#endif /* !defined TZ_MAX_TYPES */
|
||||
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
||||
#endif /* !defined TZ_MAX_TYPES */
|
||||
|
||||
#ifndef TZ_MAX_CHARS
|
||||
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
||||
/* (limited by what unsigned chars can hold) */
|
||||
#endif /* !defined TZ_MAX_CHARS */
|
||||
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
||||
/* (limited by what unsigned chars can hold) */
|
||||
#endif /* !defined TZ_MAX_CHARS */
|
||||
|
||||
#ifndef TZ_MAX_LEAPS
|
||||
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
||||
#endif /* !defined TZ_MAX_LEAPS */
|
||||
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
||||
#endif /* !defined TZ_MAX_LEAPS */
|
||||
|
||||
#endif /* !defined TZFILE_H */
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
#include "absl/time/internal/cctz/include/cctz/zone_info_source.h"
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz {
|
||||
|
||||
|
|
@ -24,9 +27,11 @@ std::string ZoneInfoSource::Version() const { return std::string(); }
|
|||
|
||||
} // namespace cctz
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace time_internal {
|
||||
namespace cctz_extension {
|
||||
|
||||
|
|
@ -36,8 +41,9 @@ namespace {
|
|||
// defers to the fallback factory.
|
||||
std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource> DefaultFactory(
|
||||
const std::string& name,
|
||||
const std::function<std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>(
|
||||
const std::string& name)>& fallback_factory) {
|
||||
const std::function<
|
||||
std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>(
|
||||
const std::string& name)>& fallback_factory) {
|
||||
return fallback_factory(name);
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +59,8 @@ std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource> DefaultFactory(
|
|||
// Windows linker cannot handle that. Nor does the MinGW compiler know how to
|
||||
// pass "#pragma comment(linker, ...)" to the Windows linker.
|
||||
#if (__has_attribute(weak) || defined(__GNUC__)) && !defined(__MINGW32__)
|
||||
ZoneInfoSourceFactory zone_info_source_factory
|
||||
__attribute__((weak)) = DefaultFactory;
|
||||
ZoneInfoSourceFactory zone_info_source_factory __attribute__((weak)) =
|
||||
DefaultFactory;
|
||||
#elif defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_LIBCPP_VERSION)
|
||||
extern ZoneInfoSourceFactory zone_info_source_factory;
|
||||
extern ZoneInfoSourceFactory default_factory;
|
||||
|
|
@ -77,4 +83,5 @@ ZoneInfoSourceFactory zone_info_source_factory = DefaultFactory;
|
|||
|
||||
} // namespace cctz_extension
|
||||
} // namespace time_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue