Resolve warnings in the IFC library

This commit is contained in:
Savanni D'Gerinel 2023-10-04 16:30:50 -04:00
parent 10849687e3
commit 49b1865818
2 changed files with 3 additions and 6 deletions

View File

@ -7,7 +7,6 @@ edition = "2018"
keywords = ["date", "time", "calendar"]
categories = ["date-and-time"]
license = "GPL-3.0-only"
license-file = "../COPYING"
[dependencies]
chrono = { version = "0.4" }

View File

@ -141,9 +141,7 @@ impl IFC {
}
pub fn ymd(year: i32, month: u8, day: u8) -> Result<Self, Error> {
if month < 1 || month > 13 {
Err(Error::InvalidDate)
} else if day < 1 || day > 28 {
if !(1..=13).contains(&month) || !(1..=28).contains(&day) {
Err(Error::InvalidDate)
} else {
Ok(Self::Day(Day { year, month, day }))
@ -248,12 +246,12 @@ impl From<chrono::NaiveDate> for IFC {
if is_leap_year(date.year())
&& date > NaiveDate::from_ymd_opt(date.year(), 6, 17).unwrap()
{
days = days - 1;
days -= 1;
}
let mut month: u8 = (days / 28).try_into().unwrap();
let mut day: u8 = (days % 28).try_into().unwrap();
if day == 0 {
month = month - 1;
month -= 1;
day = 28;
}
Self::Day(Day {