Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainDate.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainDate.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainDateTime.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainDateTime.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainMonthDay.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainMonthDay.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainTime.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainTime.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainYearMonth.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/PlainYearMonth.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions temporal_capi/src/plain_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ pub mod ffi {
.map_err(Into::into)
}

pub fn equals(&self, other: &Self) -> bool {
self.0 == other.0
}

pub fn compare(one: &Self, two: &Self) -> core::cmp::Ordering {
let tuple1 = (one.iso_year(), one.iso_month(), one.iso_day());
let tuple2 = (two.iso_year(), two.iso_month(), two.iso_day());

tuple1.cmp(&tuple2)
}
pub fn year(&self) -> i32 {
self.0.year()
}
Expand Down
31 changes: 31 additions & 0 deletions temporal_capi/src/plain_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,37 @@ pub mod ffi {
.map_err(Into::into)
}

pub fn equals(&self, other: &Self) -> bool {
self.0 == other.0
}

pub fn compare(one: &Self, two: &Self) -> core::cmp::Ordering {
let tuple1 = (
one.iso_year(),
one.iso_month(),
one.iso_day(),
one.hour(),
one.minute(),
one.second(),
one.millisecond(),
one.microsecond(),
one.nanosecond(),
);
let tuple2 = (
two.iso_year(),
two.iso_month(),
two.iso_day(),
two.hour(),
two.minute(),
two.second(),
two.millisecond(),
two.microsecond(),
two.nanosecond(),
);

tuple1.cmp(&tuple2)
}

pub fn round(&self, options: RoundingOptions) -> Result<Box<Self>, TemporalError> {
self.0
.round(options.try_into()?)
Expand Down
8 changes: 8 additions & 0 deletions temporal_capi/src/plain_month_day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ pub mod ffi {
.map_err(Into::into)
}

pub fn equals(&self, other: &Self) -> bool {
self.0 == other.0
}

pub fn compare(one: &Self, two: &Self) -> core::cmp::Ordering {
(one.iso_year(), one.iso_month()).cmp(&(two.iso_year(), two.iso_month()))
}

pub fn iso_year(&self) -> i32 {
self.0.iso_year()
}
Expand Down
23 changes: 23 additions & 0 deletions temporal_capi/src/plain_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ pub mod ffi {
.map(|x| Box::new(Duration(x)))
.map_err(Into::into)
}
pub fn equals(&self, other: &Self) -> bool {
self.0 == other.0
}
pub fn compare(one: &Self, two: &Self) -> core::cmp::Ordering {
let tuple1 = (
one.hour(),
one.minute(),
one.second(),
one.millisecond(),
one.microsecond(),
one.nanosecond(),
);
let tuple2 = (
two.hour(),
two.minute(),
two.second(),
two.millisecond(),
two.microsecond(),
two.nanosecond(),
);

tuple1.cmp(&tuple2)
}
pub fn round(
&self,
smallest_unit: Unit,
Expand Down
6 changes: 6 additions & 0 deletions temporal_capi/src/plain_year_month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ pub mod ffi {
.map(|x| Box::new(Duration(x)))
.map_err(Into::into)
}
pub fn equals(&self, other: &Self) -> bool {
self.0 == other.0
}
pub fn compare(one: &Self, two: &Self) -> core::cmp::Ordering {
(one.iso_year(), one.iso_month()).cmp(&(two.iso_year(), two.iso_month()))
}
pub fn to_plain_date(&self) -> Result<Box<PlainDate>, TemporalError> {
self.0
.to_plain_date()
Expand Down