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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

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
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.

1 participant