From e73ba7f33fb40486472002ef537e820716930623 Mon Sep 17 00:00:00 2001 From: Shea Frembling Date: Tue, 3 Mar 2026 14:17:02 -0600 Subject: [PATCH] add ability to format Row correctly --- src/csv.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/csv.rs b/src/csv.rs index 194f7d5..4afb7a9 100644 --- a/src/csv.rs +++ b/src/csv.rs @@ -13,6 +13,8 @@ pub struct Row { } impl Row { + const DF: &str = "%Y-%m-%d %H:%M"; + pub fn new( name: &str, hut_type: &str, @@ -71,3 +73,25 @@ fn make_checksum() -> String { format!("{}{}", base, last) } + +impl std::fmt::Display for Row { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{},{},{},{},{},N,{},{},{},{},{},{},{},{}", + self.name, + self.name, + self.hut_type, + self.path, + self.tare, + self.mat_id, + self.quantity, + self.lot_id, + self.uom, + self.lot_status, + self.born.format(Self::DF), + self.born.format(Self::DF), + self.expire.format(Self::DF), + ) + } +}