-
Notifications
You must be signed in to change notification settings - Fork 185
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
OPTION B: Add format_unchecked functions to DateTimeFormatter via DateTimeInputUnchecked #6256
base: main
Are you sure you want to change the base?
Conversation
Let's have the discussion on which option to pick on the other PR to keep things streamlined |
I updated this PR to make the fields private and add a few public setter functions. |
} | ||
|
||
/// Sets the time zone UTC offset. | ||
pub fn set_time_zone_utc_offset(&mut self, offset: UtcOffset) { |
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.
Wanted to call out the setters I have in this current version of this PR:
set_date_fields(&mut self, input: Date<A>)
set_time_fields(&mut self, input: Time)
but for zone, I go field by field
set_time_zone_utc_offset(&mut self, offset: UtcOffset)
set_time_zone_id(&mut self, id: TimeZone)
set_time_zone_local_time(&mut self, local_time: (Date<Iso>, Time))
set_time_zone_variant(&mut self, zone_variant: TimeZoneVariant)
I did this because
- If I have type-based setters, I still have 4 setters:
UtcOffset
,TimeZoneInfo<Base>
,TimeZoneInfo<AtTime>
, andTimeZoneInfo<Full>
, which I find to be more confusing - These setters look sort-of like the TimeZoneInfo builder functions, so they are not without precedent
- What I have implemented here aligns with the needs of ZonedDateTime FFI, which is currently the only client of this function (this is a priority that caries small but nonzero weight)
CC @robertbastian, you probably have an opinion on this
Toward #5940
Alternative to #6255
In hindsight, this is a pretty obviously useful function. It took some experimentation until I arrived at it. I have two signatures: this one and the one in #6255. Please express an opinion on which one to move forward with.
How this approach works: it adds a single plain input type named
DateTimeInputUnchecked
. This type cannot be passed intoformat
because it can't implement the required traits, so it gets its own format function with fallible behavior.Pros and cons: