mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
fix: resolved warning related to deprecated method chrono::NaiveDateTime::from_timestamp_opt (#31593)
This commit is contained in:
parent
0f4522c360
commit
48f5ee828c
1 changed files with 5 additions and 2 deletions
|
@ -9,7 +9,7 @@ use std::ptr::NonNull;
|
||||||
use std::{f64, ptr};
|
use std::{f64, ptr};
|
||||||
|
|
||||||
use chrono::naive::{NaiveDate, NaiveDateTime};
|
use chrono::naive::{NaiveDate, NaiveDateTime};
|
||||||
use chrono::{Datelike, Weekday};
|
use chrono::{DateTime, Datelike, Weekday};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::FilterPattern;
|
use embedder_traits::FilterPattern;
|
||||||
use encoding_rs::Encoding;
|
use encoding_rs::Encoding;
|
||||||
|
@ -2916,7 +2916,10 @@ fn milliseconds_to_datetime(value: f64) -> Result<NaiveDateTime, ()> {
|
||||||
let seconds = (value / 1000.0).floor();
|
let seconds = (value / 1000.0).floor();
|
||||||
let milliseconds = value - (seconds * 1000.0);
|
let milliseconds = value - (seconds * 1000.0);
|
||||||
let nanoseconds = milliseconds * 1e6;
|
let nanoseconds = milliseconds * 1e6;
|
||||||
NaiveDateTime::from_timestamp_opt(seconds as i64, nanoseconds as u32).ok_or(())
|
match DateTime::from_timestamp(seconds as i64, nanoseconds as u32) {
|
||||||
|
Some(datetime) => Ok(datetime.naive_utc()),
|
||||||
|
None => Err(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is used to compile JS-compatible regex provided in pattern attribute
|
// This is used to compile JS-compatible regex provided in pattern attribute
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue