refactor: use chrono for month names
This commit is contained in:
parent
d11a35c157
commit
a8c41ec833
1 changed files with 4 additions and 16 deletions
|
|
@ -154,22 +154,10 @@ impl MonthReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the month name.
|
/// Get the month name.
|
||||||
pub fn month_name(&self) -> &'static str {
|
pub fn month_name(&self) -> String {
|
||||||
match self.month {
|
NaiveDate::from_ymd_opt(self.year, self.month, 1)
|
||||||
1 => "January",
|
.map(|d| d.format("%B").to_string())
|
||||||
2 => "February",
|
.unwrap_or_else(|| "Unknown".to_string())
|
||||||
3 => "March",
|
|
||||||
4 => "April",
|
|
||||||
5 => "May",
|
|
||||||
6 => "June",
|
|
||||||
7 => "July",
|
|
||||||
8 => "August",
|
|
||||||
9 => "September",
|
|
||||||
10 => "October",
|
|
||||||
11 => "November",
|
|
||||||
12 => "December",
|
|
||||||
_ => "Unknown",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue