refactor: remove month_from_n function
This commit is contained in:
parent
ffa1e51a2b
commit
ea80f8463d
3 changed files with 5 additions and 22 deletions
|
|
@ -18,7 +18,7 @@
|
|||
use std::ops::Mul;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::{Date, Duration, OffsetDateTime};
|
||||
use time::{Date, Duration, Month, OffsetDateTime};
|
||||
|
||||
use crate::{
|
||||
param::Language,
|
||||
|
|
@ -261,7 +261,8 @@ pub fn parse_textual_date(lang: Language, textual_date: &str) -> Option<ParsedDa
|
|||
}
|
||||
|
||||
match (y, m, d) {
|
||||
(Some(y), Some(m), Some(d)) => util::month_from_n(m as u8)
|
||||
(Some(y), Some(m), Some(d)) => Month::try_from(m as u8)
|
||||
.ok()
|
||||
.and_then(|m| Date::from_calendar_date(y.into(), m, d as u8).ok())
|
||||
.map(ParsedDate::Absolute),
|
||||
_ => None,
|
||||
|
|
|
|||
Reference in a new issue