-
Notifications
You must be signed in to change notification settings - Fork 19
Add with_*
methods to Date
and DateTime
#84
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
Conversation
src/components/date.rs
Outdated
calendar: dt.calendar().clone(), | ||
} | ||
/// Creates a | ||
pub fn with_calendar<I>(&self, calendar_like: Option<I>) -> TemporalResult<Self> |
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.
I don't think we should accept an Option<I: Into<Calendar>>
for something that only requires a calendar. We should just require users to pass the calendar directly, and delegate calling into
to them.
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.
That's fair. The intent in this instance was to try and mimic the proposal as much as possible around accepting a calendarLike
vs. a calendar
. But there's not really any negative to restricting to just a calendar. It's probably a better API too.
Mostly speaking of #55 as far as the API, but maybe that should be rethought?
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.
I think the spec API is fine, but in my opinion the APIs should be adapted to the explicitness of Rust APIs instead of having a 1-1 equivalent in both, which in this case means having some function that people can call to get the calendar before calling the function, instead of filling the API with generics.
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.
This is partly because any APIs that have generics in them will make it really difficult to implement FFI interfaces for them.
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.
Looks great!
Per title, this PR adds
with_calendar
andwith_time
methods toDate
andDateTime
. This also adds someFrom
impls forCalendar
.