Make code warning free again

This commit is contained in:
jaby 2022-11-16 01:46:28 +01:00
parent bac2d93234
commit a632b84970
1 changed files with 5 additions and 3 deletions

View File

@ -1,14 +1,16 @@
use chrono::{Duration, FixedOffset, TimeZone as ChronoTimeZone, prelude::*};
use chrono::{Duration, FixedOffset, offset::LocalResult, TimeZone as ChronoTimeZone, prelude::*};
trait DateTimeGetter {
fn get_datetime(&self) -> Option<DateTime<FixedOffset>> {
if self.get_month() == 0 || self.get_day() == 0 {
None
}
else {
Some(FixedOffset::east(self.get_timezone_sec()).ymd(self.get_year(), self.get_month(), self.get_day()).and_hms_milli(self.get_hour(), self.get_minute(), self.get_second(), self.get_milli_second()))
match FixedOffset::east_opt(self.get_timezone_sec())?.with_ymd_and_hms(self.get_year(), self.get_month(), self.get_day(), self.get_hour(), self.get_minute(), self.get_second()) {
LocalResult::Single(date_time) => date_time.with_nanosecond(self.get_milli_second()*1000*1000),
_ => None,
}
}
}