generated from PlexSheep/rs-base
Merge pull request #18 from race604/fix-lint-by-clippy
fix lint error reported by clippy
This commit is contained in:
commit
3f357f3fd2
1 changed files with 11 additions and 11 deletions
22
src/app.rs
22
src/app.rs
|
@ -273,32 +273,32 @@ fn parse_datetime(s: &str) -> Result<DateTime<Local>, String> {
|
||||||
let today = Local::today();
|
let today = Local::today();
|
||||||
|
|
||||||
let time = NaiveTime::parse_from_str(s, "%H:%M");
|
let time = NaiveTime::parse_from_str(s, "%H:%M");
|
||||||
if time.is_ok() {
|
if let Ok(time) = time {
|
||||||
let time = NaiveDateTime::new(today.naive_local(), time.unwrap());
|
let time = NaiveDateTime::new(today.naive_local(), time);
|
||||||
return Ok(Local.from_local_datetime(&time).unwrap());
|
return Ok(Local.from_local_datetime(&time).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let time = NaiveTime::parse_from_str(s, "%H:%M:%S");
|
let time = NaiveTime::parse_from_str(s, "%H:%M:%S");
|
||||||
if time.is_ok() {
|
if let Ok(time) = time {
|
||||||
let time = NaiveDateTime::new(today.naive_local(), time.unwrap());
|
let time = NaiveDateTime::new(today.naive_local(), time);
|
||||||
return Ok(Local.from_local_datetime(&time).unwrap());
|
return Ok(Local.from_local_datetime(&time).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let date = NaiveDate::parse_from_str(s, "%Y-%m-%d");
|
let date = NaiveDate::parse_from_str(s, "%Y-%m-%d");
|
||||||
if date.is_ok() {
|
if let Ok(date) = date {
|
||||||
let time = NaiveDateTime::new(date.unwrap(), NaiveTime::from_hms(0, 0, 0));
|
let time = NaiveDateTime::new(date, NaiveTime::from_hms(0, 0, 0));
|
||||||
return Ok(Local.from_local_datetime(&time).unwrap());
|
return Ok(Local.from_local_datetime(&time).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let date_time = NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M:%S");
|
let date_time = NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M:%S");
|
||||||
if date_time.is_ok() {
|
if let Ok(date_time) = date_time {
|
||||||
return Ok(Local.from_local_datetime(&date_time.unwrap()).unwrap());
|
return Ok(Local.from_local_datetime(&date_time).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let rfc_time = DateTime::parse_from_rfc3339(s);
|
let rfc_time = DateTime::parse_from_rfc3339(s);
|
||||||
if rfc_time.is_ok() {
|
if let Ok(rfc_time) = rfc_time {
|
||||||
return Ok(rfc_time.unwrap().with_timezone(&Local));
|
return Ok(rfc_time.with_timezone(&Local));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err("Invalid time format".to_string());
|
Err("Invalid time format".to_string())
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue