Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 6 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.

28 changes: 28 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.

6 changes: 6 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.

40 changes: 40 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.

6 changes: 6 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.

26 changes: 26 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.

6 changes: 6 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.

34 changes: 34 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.

6 changes: 6 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.

26 changes: 26 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.

29 changes: 29 additions & 0 deletions temporal_capi/src/plain_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,35 @@ 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) -> i32 {
Self::compare_iso_date(
one.iso_year(),
one.iso_month(),
one.iso_day(),
two.iso_year(),
two.iso_month(),
two.iso_day(),
)
}

pub fn compare_iso_date(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use the library's compare function. Don't write your own. only write a thing wrapper.

year1: i32,
month1: u8,
day1: u8,
year2: i32,
month2: u8,
day2: u8,
) -> i32 {
match (year1, month1, day1).cmp(&(year2, month2, day2)) {
std::cmp::Ordering::Less => -1,
std::cmp::Ordering::Equal => 0,
std::cmp::Ordering::Greater => 1,
}
}
pub fn year(&self) -> i32 {
self.0.year()
}
Expand Down
Loading