Commit fa69b19a by Abseil Team Committed by Copybara-Service

Import of CCTZ from GitHub.

PiperOrigin-RevId: 467950116
Change-Id: Iccb0c80c93f1064a82a5537d4519b041609cddd6
parent 59cba2b5
......@@ -554,6 +554,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
"Europe/Kaliningrad",
"Europe/Kiev",
"Europe/Kirov",
"Europe/Kyiv",
"Europe/Lisbon",
"Europe/Ljubljana",
"Europe/London",
......@@ -593,6 +594,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
"Europe/Zagreb",
"Europe/Zaporozhye",
"Europe/Zurich",
"Factory",
"GB",
"GB-Eire",
"GMT",
......
......@@ -134,6 +134,21 @@ std::int_fast64_t Decode64(const char* cp) {
return static_cast<std::int_fast64_t>(v - s64maxU - 1) - s64max - 1;
}
// Does the rule for future transitions call for year-round daylight time?
// See tz/zic.c:stringzone() for the details on how such rules are encoded.
bool AllYearDST(const PosixTimeZone& posix) {
if (posix.dst_start.date.fmt != PosixTransition::N) return false;
if (posix.dst_start.date.n.day != 0) return false;
if (posix.dst_start.time.offset != 0) return false;
if (posix.dst_end.date.fmt != PosixTransition::J) return false;
if (posix.dst_end.date.j.day != kDaysPerYear[0]) return false;
const auto offset = posix.std_offset - posix.dst_offset;
if (posix.dst_end.time.offset + offset != kSecsPerDay) return false;
return true;
}
// Generate a year-relative offset for a PosixTransition.
std::int_fast64_t TransOffset(bool leap_year, int jan1_weekday,
const PosixTransition& pt) {
......@@ -334,6 +349,7 @@ bool TimeZoneInfo::ExtendTransitions() {
PosixTimeZone posix;
if (!ParsePosixSpec(future_spec_, &posix)) return false;
if (AllYearDST(posix)) return true; // last transition still prevails
// Find transition type for the future std specification.
std::uint_least8_t std_ti;
......
......@@ -489,6 +489,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
"Europe/Kaliningrad",
"Europe/Kiev",
"Europe/Kirov",
"Europe/Kyiv",
"Europe/Lisbon",
"Europe/Ljubljana",
"Europe/London",
......@@ -528,6 +529,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
"Europe/Zagreb",
"Europe/Zaporozhye",
"Europe/Zurich",
"Factory",
"GB",
"GB-Eire",
"GMT",
......@@ -1188,11 +1190,12 @@ TEST(PrevTransition, AmericaNewYork) {
TEST(NextTransition, Scan) {
for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) {
SCOPED_TRACE(testing::Message() << "In " << *np);
time_zone tz;
// EXPECT_TRUE(load_time_zone(*np, &tz));
if (!load_time_zone(*np, &tz)) {
continue; // tolerate kTimeZoneNames/zoneinfo skew
}
SCOPED_TRACE(testing::Message() << "In " << *np);
auto tp = time_point<absl::time_internal::cctz::seconds>::min();
time_zone::civil_transition trans;
......
......@@ -13,12 +13,7 @@ New versions can be generated using the following shell script.
trap "rm -fr ${DESTDIR}" 0 2 15
(
cd ${DESTDIR}
if [ -n "${USE_GLOBAL_TZ}" ]
then
git clone -b global-tz https://github.com/JodaOrg/global-tz.git tz
else
git clone https://github.com/eggert/tz.git
fi
make --directory=tz \
install DESTDIR=${DESTDIR} \
DATAFORM=vanguard \
......@@ -26,6 +21,7 @@ New versions can be generated using the following shell script.
REDO=posix_only \
LOCALTIME=Factory \
TZDATA_TEXT= \
PACKRATDATA=backzone PACKRATLIST=zone.tab \
ZONETABLES=zone1970.tab
tar --create --dereference --hard-dereference --file tzfile.tar \
--directory=tz tzfile.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment