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

Add FFI for DateTimeFormat #2164

Merged
merged 2 commits into from
Jul 16, 2022
Merged

Add FFI for DateTimeFormat #2164

merged 2 commits into from
Jul 16, 2022

Conversation

dminor
Copy link
Contributor

@dminor dminor commented Jul 11, 2022

Fixes #1326

@dminor dminor requested a review from a team as a code owner July 11, 2022 18:16
@dminor dminor requested review from nordzilla and removed request for a team July 11, 2022 18:16
Manishearth
Manishearth previously approved these changes Jul 11, 2022
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

praise: this is coming together nicely!

pub struct ICU4XGregorianDateTime(pub DateTime<Gregorian>);

impl ICU4XGregorianDateTime {
/// Creates a new [`ICU4XGregorianDateTime`] from locale data.
Copy link
Member

Choose a reason for hiding this comment

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

nit: not from locale data

also I'd just call this new

/// An ICU4X TimeFormat object capable of formatting a [`ICU4XGregorianDateTime`] as a string,
/// using the Gregorian Calendar.
#[diplomat::rust_link(icu::datetime::TimeFormat, Struct)]
pub struct ICU4XGregorianTimeFormat(pub TimeFormat<Gregorian>);
Copy link
Member

Choose a reason for hiding this comment

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

nit: pop in a todo and a link to #2153 since we probably(?) want this to just be TimeFormat eventually


/// Formats a [`ICU4XGregorianDateTime`] to a string.
#[diplomat::rust_link(icu::datetime::TimeFormat::format_to_write, FnInStruct)]
pub fn format_to_write(
Copy link
Member

Choose a reason for hiding this comment

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

thought: should this be format_datetime_to_write()? Would we end up adding a Time type over FFI?

Copy link
Member

Choose a reason for hiding this comment

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

issue: Also, over FFI Writeables typically just return strings, I'd just call this format() (or, assuming the previous suggestion, format_datetime(). The three-way distinction on the Rust side is irrelevant here

@dminor
Copy link
Contributor Author

dminor commented Jul 12, 2022

I believe the CI failures here are due to rust-lang/rustup#3029

@sffc
Copy link
Member

sffc commented Jul 16, 2022

Going to merge based on @Manishearth's approval and because I would rather @zbraniecki than @dminor fix the naming to Formatter instead of Format

@sffc sffc merged commit 420b8da into unicode-org:main Jul 16, 2022
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.

Implement FFI for DateTimeFormat
3 participants