Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ZoneOffsetCalculator #5540

Merged
merged 9 commits into from
Sep 16, 2024
Merged

Conversation

robertbastian
Copy link
Member

#5466

Supersedes #5515

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Unsure on some of the details in datagen but the rest looks great.

components/timezone/src/lib.rs Outdated Show resolved Hide resolved
components/timezone/src/provider.rs Show resolved Hide resolved
Comment on lines +186 to +187
/// The default mapping between period and offsets. The second level key is a wall-clock time represented as
/// the number of minutes since the local unix epoch. It represents when the offsets ended to be used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: This is the opposite of MetazonePeriodV1, and in your data structs, you end up with a bunch of i32::MAX instead of 0, which will make the two data structs more difficult to merge. Is there a reason you did it this way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TZDB defines its data like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can do it in 20-30 minutes, I think I prefer storing them the same way as Metazones. If you can't do it in that amount of time, we'll just leave it a the follow-up issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and it's very messy. The rules are not guaranteed to be ordered, so you have to assemble everything first, and then convert end times to start times. For this conversion you need to keep track of the offset at that point. Not a 20 minute thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's file a follow-up issue to merge the two markers and then we'll have to do this when we merge them.

#[cfg_attr(feature = "datagen", databake(path = icu_timezone::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct ZoneOffsetPeriodV1<'data>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observation: MetazonePeriodV1 has

  "aqcas": {
    "0": "auwe",
    "20930040": "case",
    "21128580": "auwe",
    "21995640": "case",
    "22164060": "auwe",
    "24617760": "case",
    "25345020": "auwe",
    "25647600": "case",
    "25879200": "auwe",
    "26168820": "case",
    "26393280": "auwe",
    "26695681": "case",
    "26927340": "auwe",
    "27219841": "case",
    "27451500": "auwe",
    "27744001": "case",
    "27971520": "auwe"
  },

And ZoneOffsetPeriodV1 has

  "aqcas": {
    "20930520": [
      64,
      0
    ],
    "21129240": [
      88,
      0
    ],
    "21996120": [
      64,
      0
    ],
    "22164060": [
      88,
      0
    ],
    "24618240": [
      64,
      0
    ],
    "25345680": [
      88,
      0
    ],
    "25648080": [
      64,
      0
    ],
    "25879860": [
      88,
      0
    ],
    "26169300": [
      64,
      0
    ],
    "26393940": [
      88,
      0
    ],
    "26696161": [
      64,
      0
    ],
    "26928000": [
      88,
      0
    ],
    "27220321": [
      64,
      0
    ],
    "27452160": [
      88,
      0
    ],
    "27744481": [
      64,
      0
    ],
    "27972180": [
      88,
      0
    ],
    "2147483647": [
      64,
      0
    ]
  },

which seem highly correlated. There are some that match exactly, such as 22164060. There are others that are virtually the same, such as 21128580 and 21129240, differing by 11 hours, which seems more likely to be a rounding / calculation / data error than an actual difference in when the two events occurred (metazone switch and offset switch).

provider/icu4x-datagen/src/main.rs Show resolved Hide resolved
provider/source/src/tests/data.rs Show resolved Hide resolved
provider/source/src/time_zones/convert.rs Show resolved Hide resolved
provider/source/src/time_zones/convert.rs Outdated Show resolved Hide resolved
provider/source/src/time_zones/convert.rs Outdated Show resolved Hide resolved
provider/source/src/time_zones/convert.rs Show resolved Hide resolved
@sffc sffc requested review from nekevss and nordzilla and removed request for zbraniecki, Manishearth and nordzilla September 13, 2024 18:21
@sffc
Copy link
Member

sffc commented Sep 13, 2024

@nekevss and @nordzilla may want to review.

robertbastian and others added 3 commits September 13, 2024 22:30
Co-authored-by: Shane F. Carr <shane@unicode.org>
@robertbastian robertbastian requested a review from sffc September 16, 2024 09:50
@@ -0,0 +1,1459 @@
# tzdb data for Africa and environs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you are downloading the TZDB from the GitHub tag, you don't need the tests/data/tzdb directory, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I need it, unless you want cargo test to download it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it's needed for the same reason that we have a subset of CLDR JSON in the repo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@robertbastian robertbastian merged commit d6dffe2 into unicode-org:main Sep 16, 2024
28 checks passed
@robertbastian robertbastian deleted the zonevar2 branch September 16, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants