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

General API cleanup and adjustments #97

Merged
merged 4 commits into from
Oct 22, 2024
Merged

General API cleanup and adjustments #97

merged 4 commits into from
Oct 22, 2024

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented Oct 19, 2024

In general, this completes some various API housekeeping that was needed. Updates the built-ins to align with specification names, changes the exports, implements some of the general API changes to be more Rust-like.

Below are a full list of changes:

Ideally, now working with the library should look something like the below.

// previously would have been: 
// use temporal_rs::{components::{calendar::Calendar, Date, PartialDate}, options::ArithmeticOverflow};
use temporal_rs::{Date, Calendar, partial::PartialDate, options::ArithmeticOverflow};

let iso_calendar = Calendar::from_str("iso8601")?;
// Previously would have been Date::new(2020, 10, 19, iso_calendar.clone(), ArithmeticOverflow::Reject)?;
let constructed_date = Date::try_new(2020, 10, 19, iso_calendar.clone())?;
let today = PartialDate {
    year: Some(2020),
    month: Some(10),
    day: Some(19),
    ..Default::default()
};
let date_from_partial = iso_calendar.date_from_partial(&today, ArithmeticOverflow::Reject)?;

assert_eq!(constructed_date, from_partial);

In general, this does various housekeeping that was needed. Updates
the builtins to align with specification names, changes the exports,
implements some of the general API changes to be more Rust-like.
@nekevss nekevss added the C-api Changes related to the public API label Oct 19, 2024
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Nice cleanup! I found some typos, but approving preemptively.

src/components/calendar.rs Outdated Show resolved Hide resolved
src/components/calendar.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@nekevss nekevss merged commit 537ffe3 into main Oct 22, 2024
5 checks passed
@jedel1043 jedel1043 deleted the api-and-docs-cleanup branch October 22, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-api Changes related to the public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants