From f13a2f73ebdcec1c9a3723d5c7971245c142ee72 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Dec 2022 10:01:45 +0100 Subject: [PATCH] this should suffice --- src/time.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/time.rs b/src/time.rs index 47c9655..99bb532 100644 --- a/src/time.rs +++ b/src/time.rs @@ -268,19 +268,35 @@ impl TimeReader for CdsShortTimeProvider { } } +/// Module to generate the ASCII timecodes specified in +/// [CCSDS 301.0-B-4](https://public.ccsds.org/Pubs/301x0b4e1.pdf) section 3.5 . pub mod ascii { use chrono::format::{DelayedFormat, StrftimeItems}; use chrono::{DateTime, Utc}; + /// Tuple of format string and formatted size for time code A. + /// + /// YYYY-MM-DDThh:mm:ss.ddd + /// + /// Three digits are used for the decimal fraction pub const FMT_STR_CODE_A_WITH_SIZE: (&str, usize) = ("%FT%T%.3f", 23); + /// Tuple of format string and formatted size for time code A. + /// + /// YYYY-MM-DDThh:mm:ss.dddZ + /// + /// Three digits are used for the decimal fraction and a terminator is added at the end. pub const FMT_STR_CODE_A_TERMINATED_WITH_SIZE: (&str, usize) = ("%FT%T%.3fZ", 24); + /// Generates a time code formatter using the [FMT_STR_CODE_A_WITH_SIZE] format. + /// See [chrono::DateTime::format] for a usage example. #[cfg(feature = "alloc")] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn generate_time_code_a(date: &DateTime) -> DelayedFormat> { date.format(FMT_STR_CODE_A_WITH_SIZE.0) } + /// Generates a time code formatter using the [FMT_STR_CODE_A_TERMINATED_WITH_SIZE] format. + /// See [chrono::DateTime::format] for a usage example. #[cfg(feature = "alloc")] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn generate_time_code_a_terminated(