fix error on daylight saving time change
This commit is contained in:
parent
157962af8e
commit
e5444dde72
23
src/ip.rs
23
src/ip.rs
@ -1,6 +1,7 @@
|
|||||||
use crate::config::httpclient;
|
use crate::config::httpclient;
|
||||||
use crate::utils::gethostname;
|
use crate::utils::gethostname;
|
||||||
|
|
||||||
|
use chrono::offset::LocalResult;
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use ipnet::IpNet;
|
use ipnet::IpNet;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
@ -156,16 +157,18 @@ fn parse_date(input: regex::Captures) -> DateTime<Local> {
|
|||||||
hms.push(input.get(i).unwrap().as_str().parse::<u64>().unwrap());
|
hms.push(input.get(i).unwrap().as_str().parse::<u64>().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let date = Local
|
let date: DateTime<Local> = match Local.with_ymd_and_hms(
|
||||||
.with_ymd_and_hms(
|
ymd[0] as i32,
|
||||||
ymd[0] as i32,
|
ymd[1] as u32,
|
||||||
ymd[1] as u32,
|
ymd[2] as u32,
|
||||||
ymd[2] as u32,
|
hms[0] as u32,
|
||||||
hms[0] as u32,
|
hms[1] as u32,
|
||||||
hms[1] as u32,
|
hms[2] as u32,
|
||||||
hms[2] as u32,
|
) {
|
||||||
)
|
LocalResult::Single(s) => s,
|
||||||
.unwrap();
|
LocalResult::Ambiguous(a, _b) => a,
|
||||||
|
LocalResult::None => Local::now(),
|
||||||
|
};
|
||||||
date
|
date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user