From 404b365c75adcbd86b2c4fa6011aab2d119bbcfd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 3 Jan 2026 16:41:16 -0800 Subject: [PATCH] cleanup --- rust/pspp/src/spv/read/legacy_xml.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index f669223ca0..3778e554d5 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -203,9 +203,14 @@ impl Visualization { footnotes, ) } - fn decode_date(&self) -> Result { - NaiveDate::parse_from_str(&self.date, "%Y-%m-%d") - .map_err(|_| LegacyXmlWarning::InvalidCreationDate(self.date.clone())) + fn decode_date(&self, warn: &mut dyn FnMut(LegacyXmlWarning)) -> Option { + match NaiveDate::parse_from_str(&self.date, "%Y-%m-%d") { + Ok(date) => Some(date.into()), + Err(_) => { + warn(LegacyXmlWarning::InvalidCreationDate(self.date.clone())); + None + } + } } pub fn decode_series( &self, @@ -605,7 +610,7 @@ impl Visualization { } } - pub fn graph(&self) -> Result<&Graph, super::Error> { + fn graph(&self) -> Result<&Graph, super::Error> { for child in &self.children { match child { VisChild::Graph(g) => return Ok(g), @@ -644,13 +649,6 @@ impl Visualization { warn, ); - let date = match self.decode_date() { - Ok(date) => Some(date.into()), - Err(w) => { - warn(w); - None - } - }; let mut pivot_table = PivotTable::new( dims.into_iter() .map(|dim| (dim.axis, dim.dimension)) @@ -661,7 +659,7 @@ impl Visualization { .with_data(data) .with_layer(¤t_layer) .with_decimal(Decimal::for_lang(&self.lang)) - .with_date(date); + .with_date(self.decode_date(warn)); if let Some(title) = title { pivot_table = pivot_table.with_title(title); -- 2.30.2