deep_time/dt/
to_ccsds_str.rs1use crate::{Dt, DtErr, Scale};
2use alloc::string::String;
3
4impl Dt {
5 #[inline]
13 pub fn to_ccsds_str(&self, current: Scale) -> Result<String, DtErr> {
14 self.to_ccsds_str_nf(current, 18)
15 }
16
17 pub fn to_ccsds_str_nf(&self, current: Scale, max_precision: usize) -> Result<String, DtErr> {
19 let prec = max_precision.min(18);
20 let fmt = alloc::format!("%Y-%m-%dT%H:%M:%S%.{}~fZ", prec);
21 self.to_str_with_offset(current, &fmt, 0)
22 }
23
24 #[inline]
28 pub fn to_ccsds_doy_str(&self, current: Scale) -> Result<String, DtErr> {
29 self.to_ccsds_doy_str_nf(current, 18)
30 }
31
32 pub fn to_ccsds_doy_str_nf(
34 &self,
35 current: Scale,
36 max_precision: usize,
37 ) -> Result<String, DtErr> {
38 let prec = max_precision.min(18);
39 let fmt = alloc::format!("%Y-%jT%H:%M:%S%.{}~fZ", prec);
40 self.to_str_with_offset(current, &fmt, 0)
41 }
42}