Skip to content

Commit fa69b19

Browse files
Abseil Teamcopybara-github
authored andcommitted
Import of CCTZ from GitHub.
PiperOrigin-RevId: 467950116 Change-Id: Iccb0c80c93f1064a82a5537d4519b041609cddd6
1 parent 59cba2b commit fa69b19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+24
-7
lines changed

absl/time/internal/cctz/src/cctz_benchmark.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
554554
"Europe/Kaliningrad",
555555
"Europe/Kiev",
556556
"Europe/Kirov",
557+
"Europe/Kyiv",
557558
"Europe/Lisbon",
558559
"Europe/Ljubljana",
559560
"Europe/London",
@@ -593,6 +594,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
593594
"Europe/Zagreb",
594595
"Europe/Zaporozhye",
595596
"Europe/Zurich",
597+
"Factory",
596598
"GB",
597599
"GB-Eire",
598600
"GMT",

absl/time/internal/cctz/src/time_zone_info.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ std::int_fast64_t Decode64(const char* cp) {
134134
return static_cast<std::int_fast64_t>(v - s64maxU - 1) - s64max - 1;
135135
}
136136

137+
// Does the rule for future transitions call for year-round daylight time?
138+
// See tz/zic.c:stringzone() for the details on how such rules are encoded.
139+
bool AllYearDST(const PosixTimeZone& posix) {
140+
if (posix.dst_start.date.fmt != PosixTransition::N) return false;
141+
if (posix.dst_start.date.n.day != 0) return false;
142+
if (posix.dst_start.time.offset != 0) return false;
143+
144+
if (posix.dst_end.date.fmt != PosixTransition::J) return false;
145+
if (posix.dst_end.date.j.day != kDaysPerYear[0]) return false;
146+
const auto offset = posix.std_offset - posix.dst_offset;
147+
if (posix.dst_end.time.offset + offset != kSecsPerDay) return false;
148+
149+
return true;
150+
}
151+
137152
// Generate a year-relative offset for a PosixTransition.
138153
std::int_fast64_t TransOffset(bool leap_year, int jan1_weekday,
139154
const PosixTransition& pt) {
@@ -334,6 +349,7 @@ bool TimeZoneInfo::ExtendTransitions() {
334349

335350
PosixTimeZone posix;
336351
if (!ParsePosixSpec(future_spec_, &posix)) return false;
352+
if (AllYearDST(posix)) return true; // last transition still prevails
337353

338354
// Find transition type for the future std specification.
339355
std::uint_least8_t std_ti;

absl/time/internal/cctz/src/time_zone_lookup_test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
489489
"Europe/Kaliningrad",
490490
"Europe/Kiev",
491491
"Europe/Kirov",
492+
"Europe/Kyiv",
492493
"Europe/Lisbon",
493494
"Europe/Ljubljana",
494495
"Europe/London",
@@ -528,6 +529,7 @@ const char* const kTimeZoneNames[] = {"Africa/Abidjan",
528529
"Europe/Zagreb",
529530
"Europe/Zaporozhye",
530531
"Europe/Zurich",
532+
"Factory",
531533
"GB",
532534
"GB-Eire",
533535
"GMT",
@@ -1188,11 +1190,12 @@ TEST(PrevTransition, AmericaNewYork) {
11881190

11891191
TEST(NextTransition, Scan) {
11901192
for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) {
1193+
SCOPED_TRACE(testing::Message() << "In " << *np);
11911194
time_zone tz;
1195+
// EXPECT_TRUE(load_time_zone(*np, &tz));
11921196
if (!load_time_zone(*np, &tz)) {
11931197
continue; // tolerate kTimeZoneNames/zoneinfo skew
11941198
}
1195-
SCOPED_TRACE(testing::Message() << "In " << *np);
11961199

11971200
auto tp = time_point<absl::time_internal::cctz::seconds>::min();
11981201
time_zone::civil_transition trans;

absl/time/internal/cctz/testdata/README.zoneinfo

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@ New versions can be generated using the following shell script.
1313
trap "rm -fr ${DESTDIR}" 0 2 15
1414
(
1515
cd ${DESTDIR}
16-
if [ -n "${USE_GLOBAL_TZ}" ]
17-
then
18-
git clone -b global-tz https://github.com/JodaOrg/global-tz.git tz
19-
else
20-
git clone https://github.com/eggert/tz.git
21-
fi
16+
git clone https://github.com/eggert/tz.git
2217
make --directory=tz \
2318
install DESTDIR=${DESTDIR} \
2419
DATAFORM=vanguard \
2520
TZDIR=/zoneinfo \
2621
REDO=posix_only \
2722
LOCALTIME=Factory \
2823
TZDATA_TEXT= \
24+
PACKRATDATA=backzone PACKRATLIST=zone.tab \
2925
ZONETABLES=zone1970.tab
3026
tar --create --dereference --hard-dereference --file tzfile.tar \
3127
--directory=tz tzfile.h
570 Bytes
Binary file not shown.
-40 Bytes
Binary file not shown.
-21 Bytes
Binary file not shown.
-21 Bytes
Binary file not shown.
28 Bytes
Binary file not shown.
-49 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)