Resolve warnings in the IFC library
This commit is contained in:
parent
598e9a01f8
commit
d7a810c50b
|
@ -7,7 +7,6 @@ edition = "2018"
|
||||||
keywords = ["date", "time", "calendar"]
|
keywords = ["date", "time", "calendar"]
|
||||||
categories = ["date-and-time"]
|
categories = ["date-and-time"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
license-file = "../COPYING"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4" }
|
chrono = { version = "0.4" }
|
||||||
|
|
|
@ -141,9 +141,7 @@ impl IFC {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ymd(year: i32, month: u8, day: u8) -> Result<Self, Error> {
|
pub fn ymd(year: i32, month: u8, day: u8) -> Result<Self, Error> {
|
||||||
if month < 1 || month > 13 {
|
if !(1..=13).contains(&month) || !(1..=28).contains(&day) {
|
||||||
Err(Error::InvalidDate)
|
|
||||||
} else if day < 1 || day > 28 {
|
|
||||||
Err(Error::InvalidDate)
|
Err(Error::InvalidDate)
|
||||||
} else {
|
} else {
|
||||||
Ok(Self::Day(Day { year, month, day }))
|
Ok(Self::Day(Day { year, month, day }))
|
||||||
|
@ -248,12 +246,12 @@ impl From<chrono::NaiveDate> for IFC {
|
||||||
if is_leap_year(date.year())
|
if is_leap_year(date.year())
|
||||||
&& date > NaiveDate::from_ymd_opt(date.year(), 6, 17).unwrap()
|
&& 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 month: u8 = (days / 28).try_into().unwrap();
|
||||||
let mut day: u8 = (days % 28).try_into().unwrap();
|
let mut day: u8 = (days % 28).try_into().unwrap();
|
||||||
if day == 0 {
|
if day == 0 {
|
||||||
month = month - 1;
|
month -= 1;
|
||||||
day = 28;
|
day = 28;
|
||||||
}
|
}
|
||||||
Self::Day(Day {
|
Self::Day(Day {
|
||||||
|
|
Loading…
Reference in New Issue