mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
refactor: use chrono::DateTime::from_timestamp
(#23273)
`chrono::NaiveDateTime::from_timestamp_opt()` was deprecated in https://github.com/chronotope/chrono/pull/1473. Prerequisite for #23272.
This commit is contained in:
parent
214bfa37aa
commit
6157c85634
@ -14,10 +14,6 @@ pub fn utc_now() -> chrono::DateTime<chrono::Utc> {
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.expect("system time before Unix epoch");
|
||||
let naive = chrono::NaiveDateTime::from_timestamp_opt(
|
||||
now.as_secs() as i64,
|
||||
now.subsec_nanos(),
|
||||
)
|
||||
.unwrap();
|
||||
chrono::DateTime::from_naive_utc_and_offset(naive, chrono::Utc)
|
||||
chrono::DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos())
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -10,10 +10,6 @@ pub fn utc_now() -> chrono::DateTime<chrono::Utc> {
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.expect("system time before Unix epoch");
|
||||
let naive = chrono::NaiveDateTime::from_timestamp_opt(
|
||||
now.as_secs() as i64,
|
||||
now.subsec_nanos(),
|
||||
)
|
||||
.unwrap();
|
||||
chrono::DateTime::from_naive_utc_and_offset(naive, chrono::Utc)
|
||||
chrono::DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos())
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -10,10 +10,6 @@ pub fn utc_now() -> chrono::DateTime<chrono::Utc> {
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.expect("system time before Unix epoch");
|
||||
let naive = chrono::NaiveDateTime::from_timestamp_opt(
|
||||
now.as_secs() as i64,
|
||||
now.subsec_nanos(),
|
||||
)
|
||||
.unwrap();
|
||||
chrono::DateTime::from_naive_utc_and_offset(naive, chrono::Utc)
|
||||
chrono::DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos())
|
||||
.unwrap()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user