Skip to content
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
7 changes: 7 additions & 0 deletions temporal_capi/bindings/c/PlainDateTime.h

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

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

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

17 changes: 17 additions & 0 deletions temporal_capi/src/plain_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod ffi {
use crate::calendar::ffi::{AnyCalendarKind, Calendar};
use crate::duration::ffi::Duration;
use crate::error::ffi::TemporalError;
use crate::instant::ffi::I128Nanoseconds;
use crate::options::ffi::{
ArithmeticOverflow, DifferenceSettings, DisplayCalendar, RoundingOptions,
ToStringRoundingOptions,
Expand Down Expand Up @@ -135,6 +136,22 @@ pub mod ffi {
let zdt = crate::zoned_date_time::zdt_from_epoch_ms_with_provider(ms, tz.into(), p)?;
Ok(Box::new(Self(zdt.to_plain_date_time())))
}
#[cfg(feature = "compiled_data")]
pub fn from_epoch_nanoseconds<'p>(
ns: I128Nanoseconds,
tz: TimeZone,
p: &Provider<'p>,
) -> Result<Box<Self>, TemporalError> {
Self::from_epoch_nanoseconds_with_provider(ns, tz, &Provider::compiled())
}
pub fn from_epoch_nanoseconds_with_provider<'p>(
ns: I128Nanoseconds,
tz: TimeZone,
p: &Provider<'p>,
) -> Result<Box<Self>, TemporalError> {
let zdt = crate::zoned_date_time::zdt_from_epoch_ns_with_provider(ns, tz.into(), p)?;
Ok(Box::new(Self(zdt.to_plain_date_time())))
}
pub fn with(
&self,
partial: PartialDateTime,
Expand Down
12 changes: 12 additions & 0 deletions temporal_capi/src/zoned_date_time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::ffi::TemporalError;
use crate::instant::ffi::I128Nanoseconds;
use crate::provider::ffi::Provider;
use temporal_rs::options::RelativeTo;

Expand Down Expand Up @@ -721,6 +722,17 @@ pub(crate) fn zdt_from_epoch_ms_with_provider<'p>(
.map_err(Into::into)
}

pub(crate) fn zdt_from_epoch_ns_with_provider<'p>(
ns: I128Nanoseconds,
time_zone: temporal_rs::TimeZone,
p: &Provider<'p>,
) -> Result<temporal_rs::ZonedDateTime, TemporalError> {
let instant = temporal_rs::Instant::try_new(ns.into())?;
with_provider!(p, |p| instant
.to_zoned_date_time_iso_with_provider(time_zone, p))
.map_err(Into::into)
}

impl TryFrom<ffi::PartialZonedDateTime<'_>> for temporal_rs::partial::PartialZonedDateTime {
type Error = TemporalError;
fn try_from(other: ffi::PartialZonedDateTime<'_>) -> Result<Self, TemporalError> {
Expand Down
Loading