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,
}
}
- 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),
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))
.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);