-
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
Zoned format ffi #6233
base: main
Are you sure you want to change the base?
Zoned format ffi #6233
Conversation
// TODO: What do we do if the zone variant is not set? | ||
let zone = zone | ||
.time_zone_id | ||
.with_offset(zone.offset) | ||
.at_time(at_time) | ||
.with_zone_variant(zone.zone_variant.expect("TODO")); |
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.
Discussed with @Manishearth and it seems the simplest solution is to return an error from this function if the option is not set.
Other solutions considered and eliminated:
- Have multiple time zone types: not great because it requires multiple formatter types
- Make zone variant non-optional: not great because you only need it for specific non-location formatting
zone: &TimeZoneInfo, | ||
write: &mut diplomat_runtime::DiplomatWrite, | ||
) { | ||
let at_time = zone.local_time.unwrap_or((date.0, time.0)); |
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.
@robertbastian says this should be an error and not try to do anything clever
Finally, the NeoZonedDateTimeFormatter FFI is producing correct output. The amount of code in FFI instead of Rust is a little bit more than I'd like (a few lines of business logic that aren't just argument marshaling), but it's fine. We could move some of it into Rust in the future by adding a method to load "all data required for GenericLong formatting", for example, so that we don't need to figure out which load functions to use in each constructor. I'm still a bit stuck on what to do in the I'm trying to think of solutions. One is that I could make a custom input type specifically for FFI (one that implements all required |
#5940