mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
Replace deprecated now with now_utc (#1481)
* Replace deprecated now with now_utc * Update doctest
This commit is contained in:
@ -214,7 +214,7 @@ impl Date {
|
||||
write!(
|
||||
self,
|
||||
"{}",
|
||||
OffsetDateTime::now().format("%a, %d %b %Y %H:%M:%S GMT")
|
||||
OffsetDateTime::now_utc().format("%a, %d %b %Y %H:%M:%S GMT")
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ impl CookieBuilder {
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// let c = Cookie::build("foo", "bar")
|
||||
/// .expires(time::OffsetDateTime::now())
|
||||
/// .expires(time::OffsetDateTime::now_utc())
|
||||
/// .finish();
|
||||
///
|
||||
/// assert!(c.expires().is_some());
|
||||
|
@ -221,7 +221,7 @@ impl CookieJar {
|
||||
if self.original_cookies.contains(cookie.name()) {
|
||||
cookie.set_value("");
|
||||
cookie.set_max_age(Duration::zero());
|
||||
cookie.set_expires(OffsetDateTime::now() - Duration::days(365));
|
||||
cookie.set_expires(OffsetDateTime::now_utc() - Duration::days(365));
|
||||
self.delta_cookies.replace(DeltaCookie::removed(cookie));
|
||||
} else {
|
||||
self.delta_cookies.remove(cookie.name());
|
||||
|
@ -733,7 +733,7 @@ impl<'c> Cookie<'c> {
|
||||
pub fn make_permanent(&mut self) {
|
||||
let twenty_years = Duration::days(365 * 20);
|
||||
self.set_max_age(twenty_years);
|
||||
self.set_expires(OffsetDateTime::now() + twenty_years);
|
||||
self.set_expires(OffsetDateTime::now_utc() + twenty_years);
|
||||
}
|
||||
|
||||
fn fmt_parameters(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -19,7 +19,7 @@ fn try_parse_rfc_850(time: &str) -> Option<PrimitiveDateTime> {
|
||||
// If the `time` string contains a two-digit year, then as per RFC 2616 § 19.3,
|
||||
// we consider the year as part of this century if it's within the next 50 years,
|
||||
// otherwise we consider as part of the previous century.
|
||||
let now = OffsetDateTime::now();
|
||||
let now = OffsetDateTime::now_utc();
|
||||
let century_start_year = (now.year() / 100) * 100;
|
||||
let mut expanded_year = century_start_year + dt.year();
|
||||
|
||||
|
Reference in New Issue
Block a user