2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-10-30 11:45:45 -04:00
|
|
|
|
|
|
|
/// Identical to chrono::Utc::now() but without the system "clock"
|
|
|
|
/// feature flag.
|
|
|
|
///
|
|
|
|
/// The "clock" feature flag pulls in the "iana-time-zone" crate
|
|
|
|
/// which links to macOS's "CoreFoundation" framework which increases
|
|
|
|
/// startup time for the CLI.
|
|
|
|
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");
|
2024-04-08 17:46:54 -04:00
|
|
|
chrono::DateTime::from_timestamp(now.as_secs() as i64, now.subsec_nanos())
|
|
|
|
.unwrap()
|
2023-10-30 11:45:45 -04:00
|
|
|
}
|