Skip to content

Commit

Permalink
Apply Africa/Casablanca rearguard fix (#6112)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Feb 13, 2025
1 parent cb013ae commit b8ee1d9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
8 changes: 4 additions & 4 deletions components/timezone/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ impl FromStr for UtcOffset {
/// * `Europe/Dublin` (since 1968-10-27) sets the `isdst` flag during winter (UTC+0),
/// and does not set it during daylight saving time in summer (UTC+1). This leads
/// to incorrect display names in variant-sensitive formats:
/// * ⚠️ "Greenwhich Mean Time" in summer (UTC+1)
/// * ⚠️ "Greenwich Mean Time" in summer (UTC+1)
/// * ⚠️ "Ireland Standard Time" (the summer time name) in winter (UTC+0)
///
/// This is especially problematic as Northern Ireland (`Europe/Belfast`) sets the `isdst`
/// flag during DST (UTC+1), so it correctly uses "Greenwhich Mean Time" in the winter (and
/// flag during DST (UTC+1), so it correctly uses "Greenwich Mean Time" in the winter (and
/// "British Summer Time" in the summer).
/// * `Africa/Winkhoek` between 1994-03-20 and 2017-10-24 sets the `isdst`
/// flag during winter (UTC+1), and does not set it during daylight saving
Expand All @@ -388,8 +388,8 @@ impl FromStr for UtcOffset {
/// sets the `isdst` flag during Ramadan (UTC+0), and does not set it
/// during daylight saving time (rest of the year, UTC+1). This leads
/// to incorrect display names in variant-sensitive formats:
/// * ⚠️ "Western European Summer Time" during Ramadan (UTC+0)
/// * ⚠️ "Western European Standard Time" the rest of the year (UTC+1)
/// * ⚠️ "Morocco Daylight Time" during Ramadan (UTC+0)
/// * ⚠️ "Morocco Standard Time" the rest of the year (UTC+1)
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[zerovec::make_ule(ZoneVariantULE)]
#[repr(u8)]
Expand Down
2 changes: 1 addition & 1 deletion provider/data/timezone/data/zone_offset_period_v1.rs.data

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion provider/data/timezone/fingerprints.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bcp47/to/iana/map/v1, <singleton>, 7622B, 7600B, 35e1d2b320b41234
iana/to/bcp47/map/v3, <singleton>, 9543B, 9500B, 7218ae639c063764
windows/zones/to/bcp47/map/v1, <singleton>, 8634B, 8591B, 90b7fe3f9cadf5bd
zone/offset/period/v1, <singleton>, 13410B, 13322B, 365de2348b6c56dc
zone/offset/period/v1, <singleton>, 13410B, 13322B, dda8d1981591b7cc

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions provider/source/data/debug/timezone/ZoneOffsetPeriodV1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions provider/source/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,31 @@ impl TzdbCache {
}
}

// Morocco doesn't have have rearguard data in the text file, so we have to replicate the transform from
// ziguard.awk: https://github.com/eggert/tz/blob/271a5784a59e454b659d85948b5e65c17c11516a/ziguard.awk#L261-L299
for line in lines.iter_mut() {
if line.starts_with("Rule\tMorocco") {
let mut parts = line.split('\t').skip(2);
let from = parts.next().unwrap();
let to = parts.next().unwrap();
let _type = parts.next().unwrap();
let month = parts.next().unwrap();
let _day = parts.next().unwrap();
let _time = parts.next().unwrap();
let save = parts.next().unwrap();
if to == "2018" && month == "Oct" {
*line = line.replace("2018", "2017");
} else if from.parse::<i32>().unwrap() >= 2019 {
if save.trim() == "0" {
*line = line.replace("\t0\t", "\t1:00\t");
} else {
*line = line.replace("\t-1:00\t", "\t0\t");
}
}
}
*line = line.replace("1:00\tMorocco\t%z", "0:00\tMorocco\t+00/+01");
}

#[allow(deprecated)] // no alternative?!
let parser = LineParser::new();
let mut table = TableBuilder::new();
Expand Down

0 comments on commit b8ee1d9

Please sign in to comment.