cleanup
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jan 2026 00:41:16 +0000 (16:41 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jan 2026 00:41:16 +0000 (16:41 -0800)
rust/pspp/src/spv/read/legacy_xml.rs

index f669223ca0907f26e77b356b4f2d66f414407989..3778e554d5dd0e147c18951b2b34fd5848a0fa5b 100644 (file)
@@ -203,9 +203,14 @@ impl Visualization {
             footnotes,
         )
     }
-    fn decode_date(&self) -> Result<NaiveDate, LegacyXmlWarning> {
-        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<NaiveDateTime> {
+        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(&current_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);