Skip to content

[capi] Add is_valid() to I128Nanoseconds #363

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

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions temporal_capi/bindings/c/I128Nanoseconds.h

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

2 changes: 2 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/I128Nanoseconds.d.hpp

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

7 changes: 7 additions & 0 deletions temporal_capi/bindings/cpp/temporal_rs/I128Nanoseconds.hpp

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

7 changes: 7 additions & 0 deletions temporal_capi/src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ pub mod ffi {
pub low: u64,
}

impl I128Nanoseconds {
pub fn is_valid(self) -> bool {
let ns = i128::from(self);
temporal_rs::unix_time::EpochNanoseconds::try_from(ns).is_ok()
}
}

impl Instant {
pub fn try_new(ns: I128Nanoseconds) -> Result<Box<Self>, TemporalError> {
temporal_rs::Instant::try_new(ns.into())
Expand Down