From a8c41ec8335b3a819dddb57238b1f0d98da28ba2 Mon Sep 17 00:00:00 2001 From: Konstantin Fickel Date: Thu, 2 Apr 2026 18:18:48 +0200 Subject: [PATCH] refactor: use chrono for month names --- src/timesheet/report.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/timesheet/report.rs b/src/timesheet/report.rs index f96370d..8c405d8 100644 --- a/src/timesheet/report.rs +++ b/src/timesheet/report.rs @@ -154,22 +154,10 @@ impl MonthReport { } /// Get the month name. - pub fn month_name(&self) -> &'static str { - match self.month { - 1 => "January", - 2 => "February", - 3 => "March", - 4 => "April", - 5 => "May", - 6 => "June", - 7 => "July", - 8 => "August", - 9 => "September", - 10 => "October", - 11 => "November", - 12 => "December", - _ => "Unknown", - } + pub fn month_name(&self) -> String { + NaiveDate::from_ymd_opt(self.year, self.month, 1) + .map(|d| d.format("%B").to_string()) + .unwrap_or_else(|| "Unknown".to_string()) } }