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

TimeZone + ResolvedTimeZone #5549

Closed
wants to merge 12 commits into from
Closed

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian marked this pull request as ready for review September 17, 2024 18:29
@robertbastian robertbastian requested review from sffc and removed request for zbraniecki and nordzilla September 17, 2024 18:29
/// ```
///
/// [`CustomZonedDateTime::try_iso_from_str`]: crate::CustomZonedDateTime::try_iso_from_str
/// [`ZonedDateTime::try_iso_from_str`]: crate::ZonedDateTime::try_iso_from_str
#[cfg(feature = "compiled_data")]
#[inline]
pub fn try_from_str(s: &str) -> Result<Self, UnknownTimeZoneError> {
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 should support parsing -0500[America/Chicago]

Copy link
Member Author

Choose a reason for hiding this comment

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

We should, we already have the code through ixdtf.

components/datetime/src/neo_marker.rs Outdated Show resolved Hide resolved
Comment on lines 46 to 47
metazone_calculator: &MetazoneCalculator,
zone_offset_calculator: &ZoneOffsetCalculator,
Copy link
Member

Choose a reason for hiding this comment

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

This feels obvious, but we should probably try to merge these down to one type. I can't think of any use case where someone would want to load a MetazoneCalculator and a ZoneOffsetCalculator from different data sources.

Copy link
Member

Choose a reason for hiding this comment

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

I think for now just keep MetazoneCalculator and add the zone offset data marker to its signature. It will load two data payloads. Eventually we should merge the data payloads into one.

components/timezone/src/zoned_datetime.rs Outdated Show resolved Hide resolved
Comment on lines +231 to +234
/// The CLDR metazone identifier
pub fn metazone_id(&self) -> Option<MetazoneId> {
self.metazone_id
}
Copy link
Member

Choose a reason for hiding this comment

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

Issue: I do still feel it is useful/necessary to give a way to make one of these from IDs without data.

If we keep CustomTimeZone, it gives that low-level power for anyone who needs it.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is already a way to make one of these IDs without data: MetazoneId(tinystr!(_, "usce")). If we teach the datetime formatter to format this, our job is done. I do not want anyone to be able to construct the combination of chzrh and usce.

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 teach the datetime formatter to format this

Ok.

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: Looks a lot better! Please make CI happy and then we can land this. I think we should also merge the two calculators into a single type before 2.0, too (not necessarily the data structs).

@robertbastian
Copy link
Member Author

The build failures are FFI, which I can get to tomorrow.

@robertbastian robertbastian changed the title Concept: TimeZone + FormattableTimeZone TimeZone + FormattableTimeZone Sep 19, 2024
@robertbastian robertbastian changed the title TimeZone + FormattableTimeZone TimeZone + ResolvedTimeZone Sep 19, 2024
Comment on lines +69 to +70
time_zone: &TimeZone,
timezone_calculator: &TimeZoneCalculator,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Do the same abstraction in FFI as you have in Rust, instead of passing the timezone calculator in here

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do that when we have finalised all Rust APIs (timezone and datetime). It's a lot of work.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I thought we were mostly finalized, but from #5533 now I understand that we're not

///
/// [data provider]: icu_provider
#[derive(Debug)]
pub struct MetazoneCalculator {
pub struct TimeZoneCalculator {
Copy link
Member

Choose a reason for hiding this comment

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

Discussion: Not sure about the name TimeZoneCalculator. I would expect such a name to be reserved for a TZDB calculator.

@robertbastian robertbastian marked this pull request as draft September 23, 2024 10:14
@robertbastian robertbastian deleted the tztype branch October 16, 2024 23:30
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