diff options
Diffstat (limited to 'crates/core/thin_edge_json/src/measurement.rs')
-rw-r--r-- | crates/core/thin_edge_json/src/measurement.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/core/thin_edge_json/src/measurement.rs b/crates/core/thin_edge_json/src/measurement.rs index a458372d..13be5190 100644 --- a/crates/core/thin_edge_json/src/measurement.rs +++ b/crates/core/thin_edge_json/src/measurement.rs @@ -1,5 +1,4 @@ -use chrono::offset::FixedOffset; -use chrono::DateTime; +use time::OffsetDateTime; /// The `MeasurementVisitor` trait represents the capability to visit a series of measurements, possibly grouped. /// @@ -7,7 +6,8 @@ use chrono::DateTime; /// /// ``` /// # use thin_edge_json::measurement::*; -/// # use chrono::*; +/// # use time::{OffsetDateTime, format_description}; +/// /// struct MeasurementPrinter { /// group: Option<String>, /// } @@ -27,9 +27,11 @@ use chrono::DateTime; /// impl MeasurementVisitor for MeasurementPrinter { /// type Error = MeasurementError; /// -/// fn visit_timestamp(&mut self, timestamp: DateTime<FixedOffset>) -> Result<(), Self::Error> { +/// fn visit_timestamp(&mut self, timestamp: OffsetDateTime) -> Result<(), Self::Error> { +/// let format = +/// format_description::parse("[day] [month repr:short] [year] [hour repr:24]:[minute]:[seconds] [offset_hour sign:mandatory]:[offset_minute]").unwrap(); /// if self.group.is_none() { -/// Ok(println!("time = {}", timestamp.to_rfc2822())) +/// Ok(println!("time = {}", timestamp.format(&format).unwrap())) /// } else { /// Err(MeasurementError::UnexpectedTimestamp) /// } @@ -67,7 +69,7 @@ pub trait MeasurementVisitor { type Error: std::error::Error + std::fmt::Debug; /// Set the timestamp shared by all the measurements of this series. - fn visit_timestamp(&mut self, value: DateTime<FixedOffset>) -> Result<(), Self::Error>; + fn visit_timestamp(&mut self, value: OffsetDateTime) -> Result<(), Self::Error>; /// Add a new measurement, attached to the current group if any. fn visit_measurement(&mut self, name: &str, value: f64) -> Result<(), Self::Error>; |