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.
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue