Stop using time@0.1 in Servo (#33394)

This removes the last few uses of `time@0.1` in Servo. There are still
dependencies from `style` and `webrender`, but they will be removed soon
as well. The uses of this version of `time` are replaced with
`std::time` types and `time@0.3` when negative `Duration` is necessary.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-09-11 00:09:56 -07:00 committed by GitHub
parent 095590e224
commit bc8d8b62c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 88 additions and 103 deletions

View file

@ -17,6 +17,7 @@ use std::time::{Duration, Instant};
use base::cross_process_instant::CrossProcessInstant;
use base::id::BrowsingContextId;
use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg};
use chrono::Local;
use content_security_policy::{self as csp, CspList};
use cookie::Cookie;
use cssparser::match_ignore_ascii_case;
@ -4625,15 +4626,14 @@ impl DocumentMethods for Document {
// https://html.spec.whatwg.org/multipage/#dom-document-lastmodified
fn LastModified(&self) -> DOMString {
match self.last_modified {
Some(ref t) => DOMString::from(t.clone()),
None => DOMString::from(
time::now()
.strftime("%m/%d/%Y %H:%M:%S")
.unwrap()
.to_string(),
),
}
DOMString::from(self.last_modified.as_ref().cloned().unwrap_or_else(|| {
// Ideally this would get the local time using `time`, but `time` always fails to get the local
// timezone on Unix unless the application is single threaded unless the library is explicitly
// set to "unsound" mode. Maybe that's fine, but it needs more investigation. see
// https://nvd.nist.gov/vuln/detail/CVE-2020-26235
// When `time` supports a thread-safe way of getting the local time zone we could use it here.
Local::now().format("%m/%d/%Y %H:%M:%S").to_string()
}))
}
// https://dom.spec.whatwg.org/#dom-document-createrange