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

TimeZoneInfo #5691

Merged
merged 22 commits into from
Oct 16, 2024
Merged

TimeZoneInfo #5691

merged 22 commits into from
Oct 16, 2024

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian marked this pull request as ready for review October 15, 2024 23:23
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.

Praise: Good job getting all the boilerplate together

components/datetime/src/format/datetime.rs Outdated Show resolved Hide resolved
components/datetime/src/format/datetime.rs Outdated Show resolved Hide resolved
components/datetime/src/neo_marker.rs Outdated Show resolved Hide resolved
components/datetime/src/neo_marker.rs Outdated Show resolved Hide resolved
components/datetime/src/neo_marker.rs Outdated Show resolved Hide resolved
Comment on lines 2264 to +2267
type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, yes);
type TimeZoneMetazoneInput = datetime_marker_helper!(@input/timezone/metazone, yes);
type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes);
type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, yes);
type TimeZoneLocalTimeInput = datetime_marker_helper!(@input/timezone/local_time, yes);
Copy link
Member

Choose a reason for hiding this comment

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

Thought: we could start being more strict with the input fields. Currently this code requires that the input type returns all four of the time zone input fields, even if using a format that doesn't require them. (Can be a low-priority follow-up)

components/datetime/src/neo_marker.rs Show resolved Hide resolved
ffi/capi/src/timezone.rs Show resolved Hide resolved
@@ -3025,6 +3087,8 @@ impl DateTimeNamesMarker for NeoSkeleton {
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, yes);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, yes);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, yes);
type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods, yes);
type Offsets = datetime_marker_helper!(@names/zone/offsets, yes);
Copy link
Member

Choose a reason for hiding this comment

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

You mentioned today that you were thinking about making ZoneVariant required on the input.

I'm ultimately fine with this, but I do think that the zone variant calculator is useful to our clients, both now and in the future. So, if we do this, I think we should keep the zone variant calculator where it is, external to icu_datetime.

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 do think that the zone variant calculator is useful to our clients

I don't think it is. It performs a very small subset of TZ calculations, I don't really see how that is something we should support, and the rest of the calculations isn't. I'm happy making zone variant required, and not exposing a zone calculator. We also don't expose an offset calculator, which is very similar (goes from ID + datetime to offset).

Copy link
Member

Choose a reason for hiding this comment

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

We also don't expose an offset calculator, which is very similar (goes from ID + datetime to offset).

These are two very different operations. Figuring out the zone variant requires a very similar shape of data as figuring out the metazone. Figuring out the actual offset requires full TZDB. Figuring out the zone variant involves looking at big ranges that last decades; figuring out the offset requires looking at the transitions each and every year.

My position is that ICU4X should support formatting of a standard full IXDTF string, which is time zone ID and offset.

You seem to think that the code you spent a few weeks writing for zone variant calculations is flawed, but I don't see how it is fundamentally flawed.

Copy link
Member Author

Choose a reason for hiding this comment

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

My position is that ICU4X should support formatting of a standard full IXDTF string, which is time zone ID and offset.

I don't think IXDTF is the magical input format you want it to be.

//! let time_zone = TimeZoneInfo {
//! time_zone_id: mapper.as_borrowed().iana_to_bcp47("America/Chicago"),
//! offset: Some(UtcOffset::from_eighths_of_hour(-6 * 8)),
//! local_time: Some((datetime.date, datetime.time)),
Copy link
Member

Choose a reason for hiding this comment

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

Thought: internally we always convert this to a local timestamp. Maybe we should take a LocalTimestamp (new type) instead of the weird tuple.

Copy link
Member Author

Choose a reason for hiding this comment

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

A timestamp in local-time minutes is so odd, I don't want to expose that. This should stay a internal encoding of (Date<Iso>, Time).

Copy link
Member

Choose a reason for hiding this comment

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

If we exposed it, I would say to use an i64 local-seconds timestamp, which is slightly less weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

The local thing is the big weirdness, not the minutes.

@Manishearth Manishearth removed their request for review October 16, 2024 15:12
sffc
sffc previously approved these changes Oct 16, 2024
sffc
sffc previously approved these changes Oct 16, 2024
components/timezone/src/ixdtf.rs Outdated Show resolved Hide resolved
robertbastian and others added 2 commits October 16, 2024 14:20
Co-authored-by: Shane F. Carr <shane@unicode.org>
@robertbastian robertbastian merged commit f99af85 into unicode-org:main Oct 16, 2024
28 checks passed
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