Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: drop time crate in favor of std::time::SystemTime #2059

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion neqo-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ env_logger = { version = "0.10", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
log = { workspace = true }
qlog = { workspace = true }
time = { version = "0.3", default-features = false, features = ["formatting"] }

[dev-dependencies]
test-fixture = { path = "../test-fixture" }
Expand Down
12 changes: 5 additions & 7 deletions neqo-common/src/qlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{
io::BufWriter,
path::PathBuf,
rc::Rc,
time::SystemTime,
};

use qlog::{
Expand Down Expand Up @@ -172,13 +173,10 @@ pub fn new_trace(role: Role) -> qlog::TraceSeq {
common_fields: Some(CommonFields {
group_id: None,
protocol_type: None,
reference_time: {
// It is better to allow this than deal with a conversion from i64 to f64.
// We can't do the obvious two-step conversion with f64::from(i32::try_from(...)),
// because that overflows earlier than is ideal. This should be fine for a while.
#[allow(clippy::cast_precision_loss)]
Some((time::OffsetDateTime::now_utc().unix_timestamp() * 1000) as f64)
},
reference_time: SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map(|d| d.as_secs_f64() * 1_000.0)
.ok(),
time_format: Some("relative".to_string()),
}),
}
Expand Down
Loading