/* * advotracker - Hotline tackingtool for Advocats * * Copyright 2020 Ralf Zerres * SPDX-License-Identifier: (0BSD or MIT) */ //use chrono::{Local, DateTime}; use locales::t; use std::error::Error; use tracing::trace; /// export as csv format /// https://docs.rs/csv/1.1.3/csv/cookbook/index.html /// https://blog.burntsushi.net/csv/ pub fn export(p: &mut String, lang: &str) -> Result<(), Box> { use std::fs::File; use std::path::Path; //use std::ffi::OsStr; let mut res = t!("csv.export.started", lang); let mut state = t!("state.started", lang); trace!(target: "csv-export", process = ?res, state = ?state); // Note: slash syntax also works on Windows! let path = Path::new(p); // open the file let file = File::open(path)?; trace!(target: "csv.export", extension = ?path.extension(), file = ?file); state = t!("state.finished", lang); res = t!("csv.export.finished", lang); trace!(target: "csv-export", process = ?res, state = ?state); Ok(()) }