-
Notifications
You must be signed in to change notification settings - Fork 182
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
Respect length in zone fieldsets #6029
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine, but I believe @sffc bounced back and forth on some designes around this, so I'll let him decide
Issue: this looks like it basically undoes much of what I implemented in #5936, which was the result of multiple tradeoffs and I believe landed at the best overall design. I would have really appreciated a discussion about this before you went and implemented a change to it. |
It looks like there was also no discussion on #5936, you just went ahead and implemented something. You added the short data to the |
pub fn with_zone_location(self) -> Combo<Self, L> { | ||
Combo::new(self, L::new()) | ||
/// Associates this field set with a time zone format. | ||
pub fn with_zone<Z: ZoneMarkers>(self, zone: Z) -> Combo<Self, Z> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: This new signature for with_zone
is nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One concern I thought of with regard to this signature. Currently, users do not typically need to ever write out the Z
, Vs
, or other time zone field set types. This new signature requires that they do this. With the old signature, user code ends up being the comparatively more readable with_zone_specific
as opposed to with_zone(Zs::short())
.
@@ -833,11 +795,9 @@ macro_rules! impl_zone_marker { | |||
// A plain language description of the field set for documentation. | |||
description = $description:literal, | |||
// Length of the skeleton if this is the only field. | |||
length_override = $length_override:ident, | |||
$(sample_length = $sample_length:ident,)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Adding back sample_length
here means that the field set gains a length
field, which is the same length field as is used by other fields. Month and Time Zone Name lengths should be independently settable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these macros are way too complex. this works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this doesn't work. The presence of sample_length
causes the length
field to be added. The length
field should be inoperable for time zone field sets if the length derives from the type, as it has done since I landed my change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this PR is adding the length field to time zone field sets.
// TODO: Add short/long UTC offset? | ||
impl_marker_length_constructors!(O,); | ||
impl O { | ||
pub(crate) fn to_field(self) -> (fields::TimeZone, fields::FieldLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: to_field
can be done in the macro. Previously I wrote it as a switch statement between long and non-long, with the two results being arguments to the macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see a way to do this. Zs
, Vs
, Z
, V
, and O
have clear mappings between the Length
and the FieldLength
, but L
and X
don't have a Length
and produce different field length. This code is very easy to understand, wrapping it in multiple macros would not be.
I noticed this yesterday and it is a bug. |
I could have left more breadcrumbs about why I landed on that design, but asking on that PR why I did things a certain way, even after the PR landed, would have been a good thing to do. |
Says you. How I remember the design that was discussed was that |
@@ -833,11 +795,9 @@ macro_rules! impl_zone_marker { | |||
// A plain language description of the field set for documentation. | |||
description = $description:literal, | |||
// Length of the skeleton if this is the only field. | |||
length_override = $length_override:ident, | |||
$(sample_length = $sample_length:ident,)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this doesn't work. The presence of sample_length
causes the length
field to be added. The length
field should be inoperable for time zone field sets if the length derives from the type, as it has done since I landed my change.
Yes, and I altered that design in #5936, while you were away. I'm happy to reopen that discussion if there was something wrong with the decision I made, but it's awkward to do it on a PR that basically reverts #5936. #5936 should have removed the short data and it is a bug that it didn't. |
It's not ideal that this PR was opened at this time since I am currently making large-ish changes to some of these files (especially builder.rs and in icu_capi) to update the datetime FFI. I intend to continue with those changes even though it will cause a merge conflict. In the future, we should discuss large/disruptive changes before we spend time on them. |
Z
,V
, andO
are all capable of formatting multiple lengths, but currently always format long. This adds the relevant constructors and integrates with the fieldset builder.I've also replaced
with_zone_specific_long()
et al by awith_zone(impl ZoneMarkers)
, as otherwise the API would have exploded: