Skip to content

Commit 065d2e6

Browse files
committed
Add to_string for Instant
1 parent 3455746 commit 065d2e6

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

temporal_capi/src/instant.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ pub mod ffi {
1010
use core::str::{self, FromStr};
1111
use diplomat_runtime::{DiplomatStr, DiplomatStr16};
1212

13+
#[cfg(feature = "compiled_data")]
14+
use crate::options::ffi::ToStringRoundingOptions;
15+
#[cfg(feature = "compiled_data")]
16+
use crate::time_zone::ffi::TimeZone;
17+
1318
#[diplomat::opaque]
1419
pub struct Instant(pub temporal_rs::Instant);
1520

@@ -132,6 +137,22 @@ pub mod ffi {
132137

133138
I128Nanoseconds { high, low }
134139
}
135-
// TODO timezone APIs
140+
141+
#[cfg(feature = "compiled_data")]
142+
pub fn to_ixdtf_string_with_compiled_data(
143+
&self,
144+
zone: Option<&TimeZone>,
145+
options: ToStringRoundingOptions,
146+
write: &mut DiplomatWrite,
147+
) -> Result<(), TemporalError> {
148+
use std::fmt::Write;
149+
let string = self.0.to_ixdtf_string(zone.map(|x| &x.0), options.into())?;
150+
// throw away the error, this should always succeed
151+
let _ = write.write_str(&string);
152+
153+
Ok(())
154+
}
155+
156+
// TODO non-compiled data timezone APIs
136157
}
137158
}

0 commit comments

Comments
 (0)