1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

Replace deprecated now with now_utc (#1481)

* Replace deprecated now with now_utc

* Update doctest
This commit is contained in:
Mikail Bagishov
2020-05-02 12:14:50 +03:00
committed by GitHub
parent c27d3fad8e
commit d5ceae2074
6 changed files with 13 additions and 13 deletions

View File

@ -163,11 +163,11 @@ where
LoggerResponse {
fut: self.service.call(req),
format: None,
time: OffsetDateTime::now(),
time: OffsetDateTime::now_utc(),
_t: PhantomData,
}
} else {
let now = OffsetDateTime::now();
let now = OffsetDateTime::now_utc();
let mut format = self.inner.format.clone();
for unit in &mut format.0 {
@ -380,12 +380,12 @@ impl FormatText {
FormatText::Percent => "%".fmt(fmt),
FormatText::ResponseSize => size.fmt(fmt),
FormatText::Time => {
let rt = OffsetDateTime::now() - entry_time;
let rt = OffsetDateTime::now_utc() - entry_time;
let rt = rt.as_seconds_f64();
fmt.write_fmt(format_args!("{:.6}", rt))
}
FormatText::TimeMillis => {
let rt = OffsetDateTime::now() - entry_time;
let rt = OffsetDateTime::now_utc() - entry_time;
let rt = (rt.whole_nanoseconds() as f64) / 1_000_000.0;
fmt.write_fmt(format_args!("{:.6}", rt))
}
@ -520,7 +520,7 @@ mod tests {
.uri("/test/route/yeah")
.to_srv_request();
let now = OffsetDateTime::now();
let now = OffsetDateTime::now_utc();
for unit in &mut format.0 {
unit.render_request(now, &req);
}
@ -551,7 +551,7 @@ mod tests {
)
.to_srv_request();
let now = OffsetDateTime::now();
let now = OffsetDateTime::now_utc();
for unit in &mut format.0 {
unit.render_request(now, &req);
}
@ -561,7 +561,7 @@ mod tests {
unit.render_response(&resp);
}
let entry_time = OffsetDateTime::now();
let entry_time = OffsetDateTime::now_utc();
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, 1024, entry_time)?;
@ -579,7 +579,7 @@ mod tests {
let mut format = Format::new("%t");
let req = TestRequest::default().to_srv_request();
let now = OffsetDateTime::now();
let now = OffsetDateTime::now_utc();
for unit in &mut format.0 {
unit.render_request(now, &req);
}